CI: use a single invocation for apkbuild linting (MR 2472)

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
This commit is contained in:
Johannes Marbach 2021-08-30 11:09:02 +02:00 committed by Alexey Minnekhanov
parent 093488b82f
commit 14d2eda456
No known key found for this signature in database
GPG key ID: EBF5ECFFFEE34DED

View file

@ -13,20 +13,16 @@ if __name__ == "__main__":
print("No APKBUILDs to lint")
sys.exit(0)
issues = []
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)
package = os.path.basename(os.path.dirname(apkbuild))
result = common.run_pmbootstrap(["-q", "lint", package], output_return=True)
if len(result) > 0:
issues.append([apkbuild, result])
if len(issues) > 0:
print("Linting issues found:")
for issue in issues:
print(issue[0] + ": " + issue[1])
print(result)
sys.exit(1)