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: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7098>
This commit is contained in:
Clayton Craft
2025-09-29 12:46:33 -07:00
committed by The Friendly Merge Bot
parent fd7dd519c2
commit 95a1a60e4b
3 changed files with 24 additions and 3 deletions
+14 -2
View File
@@ -7,6 +7,8 @@ import argparse
import sys import sys
import urllib.request import urllib.request
# Same dir
import common
def get_devices() -> list[str]: def get_devices() -> list[str]:
""":returns: list of all devices""" """:returns: list of all devices"""
@@ -94,13 +96,23 @@ def main() -> int:
parser.add_argument("--path", help="instead of downloading the devices" parser.add_argument("--path", help="instead of downloading the devices"
" page from the wiki, use a local HTML file", " page from the wiki, use a local HTML file",
type=Path, default=None) 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() args = parser.parse_args()
# Check all devices
html = get_wiki_devices_html(args.path) html = get_wiki_devices_html(args.path)
html["renamed"] = get_wiki_renamed_devices_html() html["renamed"] = get_wiki_renamed_devices_html()
error = False 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): if not check_device(device, html, args.booting):
error = True error = True
+7
View File
@@ -184,3 +184,10 @@ def get_changed_kernels():
if pkgname.startswith("linux-"): if pkgname.startswith("linux-"):
ret += [pkgname] ret += [pkgname]
return ret return ret
def get_changed_devices():
ret = []
for pkgname in get_changed_packages():
if pkgname.startswith("device-"):
ret += [pkgname]
return ret
+3 -1
View File
@@ -7,9 +7,11 @@
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
set -x set -x
apk -q add \ apk -q add \
git \
python3 python3
exec su "${TESTUSER:-build}" -c "sh -e $0" exec su "${TESTUSER:-build}" -c "sh -e $0"
fi fi
set -x set -x
.ci/lib/check_devices_in_wiki.py --booting # shellcheck disable=SC2068
.ci/lib/check_devices_in_wiki.py --booting $@