From 95a1a60e4b56d792cae3492322a012a7d954de4c Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Mon, 29 Sep 2025 11:37:45 -0700 Subject: [PATCH] ci: wiki: support only running for changed devices The device wiki check currently runs for *all* devices in any given MR, and can sometimes fail (e.g. if someone edits the wiki for some unrelated device.) It's not fair to block MRs for devices when the check fails on unrelated devices. This changes the default behavior to only run on devices that are changed in the branch. This also adds an `--all` flag that restores the previous behavior, this could be run on the pmaports master branch to test general compliance for all devices without blocking MRs where the check fails for unrelated devices. Part-of: --- .ci/lib/check_devices_in_wiki.py | 16 ++++++++++++++-- .ci/lib/common.py | 7 +++++++ .ci/wiki.sh | 4 +++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.ci/lib/check_devices_in_wiki.py b/.ci/lib/check_devices_in_wiki.py index 3bc5fa8a8..3af69fbdc 100755 --- a/.ci/lib/check_devices_in_wiki.py +++ b/.ci/lib/check_devices_in_wiki.py @@ -7,6 +7,8 @@ import argparse import sys import urllib.request +# Same dir +import common def get_devices() -> list[str]: """:returns: list of all devices""" @@ -94,13 +96,23 @@ def main() -> int: parser.add_argument("--path", help="instead of downloading the devices" " page from the wiki, use a local HTML file", type=Path, default=None) + parser.add_argument("--all", help="check all devices (default: check only" + " devices changed from branch point)", + action="store_true") args = parser.parse_args() - # Check all devices html = get_wiki_devices_html(args.path) html["renamed"] = get_wiki_renamed_devices_html() error = False - for device in get_devices(): + devices = [] + if args.all: + devices = get_devices() + else: + devices = common.get_changed_devices() + # remove 'device-' prefix + devices = [d[7:] for d in devices] + devices = [d.removesuffix("-downstream") for d in devices] + for device in devices: if not check_device(device, html, args.booting): error = True diff --git a/.ci/lib/common.py b/.ci/lib/common.py index 83a4fa304..be0ac0c0e 100755 --- a/.ci/lib/common.py +++ b/.ci/lib/common.py @@ -184,3 +184,10 @@ def get_changed_kernels(): if pkgname.startswith("linux-"): ret += [pkgname] return ret + +def get_changed_devices(): + ret = [] + for pkgname in get_changed_packages(): + if pkgname.startswith("device-"): + ret += [pkgname] + return ret diff --git a/.ci/wiki.sh b/.ci/wiki.sh index de2b43568..e727234f0 100755 --- a/.ci/wiki.sh +++ b/.ci/wiki.sh @@ -7,9 +7,11 @@ if [ "$(id -u)" = 0 ]; then set -x apk -q add \ + git \ python3 exec su "${TESTUSER:-build}" -c "sh -e $0" fi set -x -.ci/lib/check_devices_in_wiki.py --booting +# shellcheck disable=SC2068 +.ci/lib/check_devices_in_wiki.py --booting $@