From 5d8cf85911cd037a98dd35fbbbad4d48380de7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Mon, 10 Aug 2026 13:08:06 +0200 Subject: [PATCH] ci: allow to fetch the complete path changed packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is useful for pytest-commits use-cases Fixes #4663 Signed-off-by: Pablo Correa Gómez Part-of: --- .ci/lib/check_changed_versions.py | 16 +++++++--------- .ci/lib/common.py | 7 +++++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.ci/lib/check_changed_versions.py b/.ci/lib/check_changed_versions.py index 102af1068..2534582a2 100755 --- a/.ci/lib/check_changed_versions.py +++ b/.ci/lib/check_changed_versions.py @@ -2,7 +2,7 @@ # Copyright 2021 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later -import glob +import os.path import pathlib import tempfile import sys @@ -25,10 +25,7 @@ def get_package_contents(package, revision, check=True): stderr = subprocess.DEVNULL # Run something like "git show upstream/main:main/hello-world/APKBUILD" - pmaports_dir = common.get_pmaports_dir() - pattern = pmaports_dir + "/**/" + package + "/APKBUILD" - path = glob.glob(pattern, recursive=True)[0][len(pmaports_dir + "/"):] - apkbuild_content = common.run_git(["show", revision + ":" + path], check, + apkbuild_content = common.run_git(["show", revision + ":" + package], check, stderr) if not apkbuild_content: return None @@ -118,8 +115,8 @@ def check_versions(packages): # Without this, .ci/commits.sh complains about the following: # ERROR: Modified package(s) don't have an increased version or a new # package has a nonzero pkgrel! - if "linux-next" in packages: - packages.remove("linux-next") + if "device/testing/linux-next" in packages: + packages.remove("device/testing/linux-next") for package in packages: # Get versions, skip new packages @@ -135,13 +132,14 @@ def check_versions(packages): # Check pkgver follows expected format for device packages pkgver = head.rpartition('-r')[0] - if package.startswith('device-') and not pkgver.isdigit(): + is_device_pkg = os.path.basename(package).startswith('device-') + if is_device_pkg and not pkgver.isdigit(): print(f" - {package}: invalid pkgver \"{pkgver}\"" "See: https://docs.postmarketos.org/pmaports/main/packaging-guidelines.html#package-versioning-pkgver-pkgrel") error = True # Additional checks for device packages - if package.startswith('device-'): + if is_device_pkg: head_parsed = get_package_contents(package, "HEAD", False) upstream_parsed = get_package_contents(package, commit, False) diff --git a/.ci/lib/common.py b/.ci/lib/common.py index d26a13eca..663e9a3ef 100755 --- a/.ci/lib/common.py +++ b/.ci/lib/common.py @@ -131,7 +131,7 @@ def get_changed_files(removed=False): return ret -def get_changed_packages(skip_archived: bool = False): +def get_changed_packages(skip_archived: bool = False, keep_dir: bool = False) -> set[str]: ret = set() for file in get_changed_files(removed=True): dirname, filename = os.path.split(file) @@ -170,7 +170,10 @@ def get_changed_packages(skip_archived: bool = False): elif not os.path.exists(file): continue # APKBUILD was deleted - ret.add(os.path.basename(dirname)) + if keep_dir: + ret.add(dirname) + else: + ret.add(os.path.basename(dirname)) return ret