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