From e0453db08f907147e5b34e8c76e43d10932d0766 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 30 Jun 2024 18:33:09 +0200 Subject: [PATCH] CI: kconfig check: just run pmbootstrap (MR 5301) Replace previous code that used internal pmbootstrap code with running pmbootstrap directly. pmbootstrap doesn't really have a stable API yet, so calling the internal code is always a bit fragile and now that we have reworked a lot of its code, this is all broken. The trade-off is that it is now slower and the output isn't as pretty, but we can finally use kconfigcheck.toml from the pmaports branch. So it is worth it! --- .ci/lib/check_changed_kernels.py | 41 ++++++++------------------------ 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/.ci/lib/check_changed_kernels.py b/.ci/lib/check_changed_kernels.py index 3bcce8266..f360818e5 100755 --- a/.ci/lib/check_changed_kernels.py +++ b/.ci/lib/check_changed_kernels.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright 2023 Oliver Smith +# Copyright 2024 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later import glob @@ -10,42 +10,25 @@ import subprocess # Same dir import common -# pmbootstrap -import add_pmbootstrap_to_import_path # noqa -import pmb.parse -import pmb.helpers.logging - -def check_kconfig(args, pkgnames): +def check_kconfig(pkgnames): last_failed = None for i in range(len(pkgnames)): pkgname = pkgnames[i] print(f" ({i+1}/{len(pkgnames)}) {pkgname}") - apkbuild_path = pmb.helpers.pmaports.find(args, pkgname) - apkbuild = pmb.parse._apkbuild.apkbuild(f"{apkbuild_path}/APKBUILD") + p = subprocess.run(["pmbootstrap", "kconfig", "check", pkgname], + check=False) - options = [] - - for opt in apkbuild["options"]: - if "pmb:kconfigcheck" in opt: - options += [opt] - - if len(options): - options.sort() - print(f'options="{" ".join(options)}"') - - if "!pmb:kconfigcheck" in apkbuild["options"]: - print("skipped (!pmb:kconfigcheck)") - continue - - if not pmb.parse.kconfig.check(args, pkgname, details=True): + if p.returncode: last_failed = pkgname return last_failed def show_error(last_failed): + print("") + print("---") print("") print("Please adjust your kernel config. This is required for getting your" " patch merged.") @@ -59,6 +42,8 @@ def show_error(last_failed): print("Run this check again (on all kernels you modified):") print(" pmbootstrap ci kconfig") print("") + print("---") + print("") if __name__ == "__main__": @@ -70,13 +55,7 @@ if __name__ == "__main__": print("No kernels changed in this branch") exit(0) - # Initialize args (so we can use pmbootstrap's kconfig parsing) - sys.argv = ["pmbootstrap", "kconfig", "check"] - args = pmb.parse.arguments() - pmb.helpers.logging.init(args) - - print("Running kconfig check on changed kernels...") - last_failed = check_kconfig(args, pkgnames) + last_failed = check_kconfig(pkgnames) if last_failed: show_error(last_failed)