ci: allow to fetch the complete path changed packages
This is useful for pytest-commits use-cases Fixes #4663 Signed-off-by: Pablo Correa Gómez <pabloyoyoista@postmarketos.org> Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/9363>
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
# Copyright 2021 Oliver Smith
|
# Copyright 2021 Oliver Smith
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import glob
|
import os.path
|
||||||
import pathlib
|
import pathlib
|
||||||
import tempfile
|
import tempfile
|
||||||
import sys
|
import sys
|
||||||
@@ -25,10 +25,7 @@ def get_package_contents(package, revision, check=True):
|
|||||||
stderr = subprocess.DEVNULL
|
stderr = subprocess.DEVNULL
|
||||||
|
|
||||||
# Run something like "git show upstream/main:main/hello-world/APKBUILD"
|
# Run something like "git show upstream/main:main/hello-world/APKBUILD"
|
||||||
pmaports_dir = common.get_pmaports_dir()
|
apkbuild_content = common.run_git(["show", revision + ":" + package], check,
|
||||||
pattern = pmaports_dir + "/**/" + package + "/APKBUILD"
|
|
||||||
path = glob.glob(pattern, recursive=True)[0][len(pmaports_dir + "/"):]
|
|
||||||
apkbuild_content = common.run_git(["show", revision + ":" + path], check,
|
|
||||||
stderr)
|
stderr)
|
||||||
if not apkbuild_content:
|
if not apkbuild_content:
|
||||||
return None
|
return None
|
||||||
@@ -118,8 +115,8 @@ def check_versions(packages):
|
|||||||
# Without this, .ci/commits.sh complains about the following:
|
# Without this, .ci/commits.sh complains about the following:
|
||||||
# ERROR: Modified package(s) don't have an increased version or a new
|
# ERROR: Modified package(s) don't have an increased version or a new
|
||||||
# package has a nonzero pkgrel!
|
# package has a nonzero pkgrel!
|
||||||
if "linux-next" in packages:
|
if "device/testing/linux-next" in packages:
|
||||||
packages.remove("linux-next")
|
packages.remove("device/testing/linux-next")
|
||||||
|
|
||||||
for package in packages:
|
for package in packages:
|
||||||
# Get versions, skip new packages
|
# Get versions, skip new packages
|
||||||
@@ -135,13 +132,14 @@ def check_versions(packages):
|
|||||||
|
|
||||||
# Check pkgver follows expected format for device packages
|
# Check pkgver follows expected format for device packages
|
||||||
pkgver = head.rpartition('-r')[0]
|
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}\""
|
print(f" - {package}: invalid pkgver \"{pkgver}\""
|
||||||
"See: https://docs.postmarketos.org/pmaports/main/packaging-guidelines.html#package-versioning-pkgver-pkgrel")
|
"See: https://docs.postmarketos.org/pmaports/main/packaging-guidelines.html#package-versioning-pkgver-pkgrel")
|
||||||
error = True
|
error = True
|
||||||
|
|
||||||
# Additional checks for device packages
|
# Additional checks for device packages
|
||||||
if package.startswith('device-'):
|
if is_device_pkg:
|
||||||
head_parsed = get_package_contents(package, "HEAD", False)
|
head_parsed = get_package_contents(package, "HEAD", False)
|
||||||
upstream_parsed = get_package_contents(package, commit, False)
|
upstream_parsed = get_package_contents(package, commit, False)
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -131,7 +131,7 @@ def get_changed_files(removed=False):
|
|||||||
return ret
|
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()
|
ret = set()
|
||||||
for file in get_changed_files(removed=True):
|
for file in get_changed_files(removed=True):
|
||||||
dirname, filename = os.path.split(file)
|
dirname, filename = os.path.split(file)
|
||||||
@@ -170,7 +170,10 @@ def get_changed_packages(skip_archived: bool = False):
|
|||||||
elif not os.path.exists(file):
|
elif not os.path.exists(file):
|
||||||
continue # APKBUILD was deleted
|
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
|
return ret
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user