14d2eda456
This replaces the current loop calling pmbootstrap lint once for each package with a single invocation for increased performance. Here are some measurements for linting all packages under main/. Before this change: $ time .gitlab-ci/apkbuild-linting.py > /dev/null real 3m55,840s user 3m48,592s sys 0m16,913s After this change but without postmarketOS/pmbootstrap!2100: $ time .gitlab-ci/apkbuild-linting.py > /dev/null real 0m14,359s user 0m17,994s sys 0m6,488s After this change with postmarketOS/pmbootstrap!2100: $ time .gitlab-ci/apkbuild-linting.py > /dev/null real 0m6,411s user 0m13,334s sys 0m2,417s Note that postmarketOS/pmbootstrap!2100 is not required for that little bit of extra performance but rather because it allows to differentiate between linting errors for different packages in the output. Depends: postmarketOS/pmbootstrap!2100 Closes: #564
28 lines
853 B
Python
Executable file
28 lines
853 B
Python
Executable file
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import common
|
|
import os.path
|
|
import sys
|
|
|
|
if __name__ == "__main__":
|
|
common.add_upstream_git_remote()
|
|
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)
|
|
|
|
packages = []
|
|
for apkbuild in apkbuilds:
|
|
if apkbuild.startswith("temp/") or apkbuild.startswith("cross/"):
|
|
print(f"NOTE: Skipping linting of {apkbuild}")
|
|
continue
|
|
packages.append(os.path.basename(os.path.dirname(apkbuild)))
|
|
|
|
result = common.run_pmbootstrap(["-q", "lint"] + packages, output_return=True)
|
|
|
|
if len(result) > 0:
|
|
print("Linting issues found:")
|
|
print(result)
|
|
sys.exit(1)
|