pmaports-a71/.ci/lib/apkbuild_linting.py
Oliver Smith 4ef0a4e9ad
CI: apkbuild_linting: fix missing output (MR 5633)
pmbootstrap used to exit with 0 if "pmbootstrap lint" failed. This was
the case in 2.3.x too, but I assumed this was a regression and fixed it
recently in pmbootstrap MR 2398.

It turns out that the CI code relied on this assumption, it captured the
output of "pmbootstrap lint", and only after it is done it checks if the
output wasn't empty and prints it in that case followed by exit 1.

Now that pmbootstrap actually exits with 1, CI already fails at
"common.run_pmbootstrap" and doesn't get to the part where it would be
printed.

I think "exit 1" on error is actually the right thing to do in
pmbootstrap, so I'll leave that in. Adjust CI to just run "pmbootstrap
lint", removing the additional output capture logic that isn't used
anywhere besides here. This also has the advantage that we get the
output "live", without buffering it completely first.
2024-10-23 13:24:06 +02:00

27 lines
802 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)))
if len(packages) < 1:
print("No APKBUILDs to lint")
sys.exit(0)
common.run_pmbootstrap(["-q", "lint"] + packages)