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.
This commit is contained in:
Minecrell 2020-03-14 12:22:08 +01:00 committed by Oliver Smith
parent 87e1b9f0b5
commit ae4931816b
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
2 changed files with 12 additions and 15 deletions

View File

@ -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:")

View File

@ -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