From ae4931816b4792fe0a282005bb3dc85d56925ff6 Mon Sep 17 00:00:00 2001 From: Minecrell Date: Sat, 14 Mar 2020 12:22:08 +0100 Subject: [PATCH] CI: apkbuild-linting: use get_changed_files() instead of get_changed_packages() (!1069) For APKBUILD linting we care only about APKBUILD files that were changed, not to which package they belong or whatever. The "with_directory" option of get_changed_packages() really meant "just give me changed files", which means that we can just use get_changed_files() instead. --- .gitlab-ci/apkbuild-linting.py | 18 +++++++++--------- .gitlab-ci/common.py | 9 +++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci/apkbuild-linting.py b/.gitlab-ci/apkbuild-linting.py index 255987ead..6c031e1e5 100755 --- a/.gitlab-ci/apkbuild-linting.py +++ b/.gitlab-ci/apkbuild-linting.py @@ -2,27 +2,27 @@ # SPDX-License-Identifier: GPL-3.0-or-later import common +import os.path import subprocess import sys if __name__ == "__main__": common.add_upstream_git_remote() - packages = common.get_changed_packages(with_directory=True) - - if len(packages) < 1: + apkbuilds = {file for file in common.get_changed_files(removed=False) + if os.path.basename(file) == "APKBUILD"} + if len(apkbuilds) < 1: print("No APKBUILDs to lint") sys.exit(0) issues = [] - for package in packages: - if "temp/" in package or \ - "cross/" in package or \ - "APKBUILD" not in package: + for apkbuild in apkbuilds: + if apkbuild.startswith("temp/") or apkbuild.startswith("cross/"): + print(f"NOTE: Skipping linting of {apkbuild}") continue - result = subprocess.run(["apkbuild-lint", package], capture_output=True) + result = subprocess.run(["apkbuild-lint", apkbuild], capture_output=True) if len(result.stdout) > 0: - issues.append([package, result.stdout.decode("utf-8")]) + issues.append([apkbuild, result.stdout.decode("utf-8")]) if len(issues) > 0: print("Linting issues found:") diff --git a/.gitlab-ci/common.py b/.gitlab-ci/common.py index f8f02c064..9400d6ed1 100755 --- a/.gitlab-ci/common.py +++ b/.gitlab-ci/common.py @@ -113,7 +113,7 @@ def get_changed_packages_sanity_check(count): sys.exit(1) -def get_changed_packages(with_directory=False): +def get_changed_packages(): files = get_changed_files() ret = set() for file in files: @@ -126,11 +126,8 @@ def get_changed_packages(with_directory=False): continue # Add to the ret set (removes duplicated automatically) - if with_directory: - ret.add(file) - else: - # device/testing/device-something/APKBUILD -> device-something - ret.add(file.split("/")[-2]) + # device/testing/device-something/APKBUILD -> device-something + ret.add(file.split("/")[-2]) return ret