ci: fix remaining ruff issues and run ruff format
We only disable LOG015 rule, as in the simple situation of pmaports, it doesn't matter too much if in pytest we are using the root logger or a custom one. 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:
@@ -21,7 +21,7 @@ custom_valid_options = [
|
||||
]
|
||||
|
||||
|
||||
def get_kconfigcheck_categories() -> list [str]:
|
||||
def get_kconfigcheck_categories() -> list[str]:
|
||||
with open("kconfigcheck.toml", "rb") as kconfigcheck_config:
|
||||
kconfigcheck_data = tomllib.load(kconfigcheck_config)
|
||||
|
||||
@@ -34,27 +34,33 @@ def get_kconfigcheck_categories() -> list [str]:
|
||||
else:
|
||||
kconfigcheck_categories.append(category_name)
|
||||
|
||||
return [item.replace("category:", "pmb:kconfigcheck-") for item in kconfigcheck_categories]
|
||||
return [
|
||||
item.replace("category:", "pmb:kconfigcheck-")
|
||||
for item in kconfigcheck_categories
|
||||
]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if common.commit_message_has_string("[ci:skip-apkbuild-lint]"):
|
||||
print("WARNING: not linting deviceinfo files ([ci:skip-apkbuild-lint])")
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
|
||||
kconfigcheck_categories = get_kconfigcheck_categories()
|
||||
custom_valid_options += kconfigcheck_categories
|
||||
os.environ["CUSTOM_VALID_OPTIONS"] = " ".join(custom_valid_options)
|
||||
|
||||
apkbuilds = {file for file in common.get_changed_files()
|
||||
if os.path.basename(file) == "APKBUILD"}
|
||||
apkbuilds = {
|
||||
file
|
||||
for file in common.get_changed_files()
|
||||
if os.path.basename(file) == "APKBUILD"
|
||||
}
|
||||
if len(apkbuilds) < 1:
|
||||
print("No APKBUILDs to lint")
|
||||
sys.exit(0)
|
||||
|
||||
apkbuilds_filtered = []
|
||||
for apkbuild in apkbuilds:
|
||||
if apkbuild.startswith("temp/") or apkbuild.startswith("cross/"):
|
||||
if apkbuild.startswith(("temp/", "cross/")):
|
||||
print(f"NOTE: Skipping linting of {apkbuild}")
|
||||
continue
|
||||
apkbuilds_filtered.append(apkbuild)
|
||||
|
||||
@@ -21,11 +21,20 @@ def build_strict(packages, arch: Arch):
|
||||
common.run_pmbootstrap(["build_init"])
|
||||
# We set the timeout to 1 hour because linking the Linux kernel with
|
||||
# ThinLTO on our aarch64 runners takes slightly over 30 minutes
|
||||
common.run_pmbootstrap(["--details-to-stdout", "--no-ccache",
|
||||
"--timeout", "3600",
|
||||
"build",
|
||||
"--strict", "--force",
|
||||
"--arch", str(arch), ] + list(packages))
|
||||
common.run_pmbootstrap(
|
||||
[
|
||||
"--details-to-stdout",
|
||||
"--no-ccache",
|
||||
"--timeout",
|
||||
"3600",
|
||||
"build",
|
||||
"--strict",
|
||||
"--force",
|
||||
"--arch",
|
||||
str(arch),
|
||||
]
|
||||
+ list(packages)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -51,7 +60,7 @@ if __name__ == "__main__":
|
||||
buildable_pkgs.add(os.path.basename(path))
|
||||
|
||||
# To store a list of packages from extra-repos/systemd for special handling later:
|
||||
systemd_pkgs = list()
|
||||
systemd_pkgs = []
|
||||
|
||||
# Filter out packages that either:
|
||||
# 1. can't be built for given arch
|
||||
@@ -92,10 +101,16 @@ if __name__ == "__main__":
|
||||
# filter out packages that can't be built for arch
|
||||
# (Iterate over copy of `systemd_pkgs`, because we modify it in this loop)
|
||||
for package in systemd_pkgs.copy():
|
||||
apkbuild_path = pmb.helpers.pmaports.find(package, True, True, with_extra_repos="enabled")
|
||||
apkbuild = pmb.parse._apkbuild.apkbuild(pathlib.Path(apkbuild_path, "APKBUILD"))
|
||||
apkbuild_path = pmb.helpers.pmaports.find(
|
||||
package, True, True, with_extra_repos="enabled"
|
||||
)
|
||||
apkbuild = pmb.parse._apkbuild.apkbuild(
|
||||
pathlib.Path(apkbuild_path, "APKBUILD")
|
||||
)
|
||||
if arch not in Arch.from_arch_field(apkbuild["arch"]):
|
||||
print(f"(extra-repos/systemd) {package}: not enabled for {arch}, skipping")
|
||||
print(
|
||||
f"(extra-repos/systemd) {package}: not enabled for {arch}, skipping"
|
||||
)
|
||||
systemd_pkgs.remove(package)
|
||||
|
||||
# No packages: skip build
|
||||
|
||||
@@ -26,8 +26,7 @@ def get_package_contents(package, revision, check=True):
|
||||
stderr = subprocess.DEVNULL
|
||||
|
||||
# Run something like "git show upstream/main:main/hello-world/APKBUILD"
|
||||
apkbuild_content = common.run_git(["show", revision + ":" + package], check,
|
||||
stderr)
|
||||
apkbuild_content = common.run_git(["show", revision + ":" + package], check, stderr)
|
||||
if not apkbuild_content:
|
||||
return None
|
||||
|
||||
@@ -36,15 +35,14 @@ def get_package_contents(package, revision, check=True):
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
with open(tempdir + "/APKBUILD", "w", encoding="utf-8") as handle:
|
||||
handle.write(apkbuild_content)
|
||||
parsed = pmb.parse.apkbuild(pathlib.Path(tempdir, "APKBUILD"),
|
||||
False, False)
|
||||
parsed = pmb.parse.apkbuild(pathlib.Path(tempdir, "APKBUILD"), False, False)
|
||||
|
||||
return parsed
|
||||
|
||||
|
||||
def get_package_version(package, revision, check=True):
|
||||
""" returns version in the format "{pkgver}-r{pkgrel}", or None if no
|
||||
matching package is found """
|
||||
"""returns version in the format "{pkgver}-r{pkgrel}", or None if no
|
||||
matching package is found"""
|
||||
parsed = get_package_contents(package, revision, check)
|
||||
if parsed is None:
|
||||
return None
|
||||
@@ -52,7 +50,7 @@ def get_package_version(package, revision, check=True):
|
||||
|
||||
|
||||
def version_compare_operator(result):
|
||||
""" :param result: return value from pmb.parse.version.compare() """
|
||||
""":param result: return value from pmb.parse.version.compare()"""
|
||||
if result == -1:
|
||||
return "<"
|
||||
elif result == 0:
|
||||
@@ -88,7 +86,7 @@ def exit_with_error_message():
|
||||
print(" latest commit message, then force push.")
|
||||
print()
|
||||
print("Thank you and sorry for the inconvenience.")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def check_versions(packages):
|
||||
@@ -101,14 +99,21 @@ def check_versions(packages):
|
||||
# desired here, since we already know what packages changed, and really
|
||||
# want to check if the version was increased towards *current* upstream
|
||||
# branch HEAD.
|
||||
common.run_git(["remote", "add", "upstream",
|
||||
"https://gitlab.postmarketos.org/postmarketOS/pmaports.git"], False)
|
||||
common.run_git(
|
||||
[
|
||||
"remote",
|
||||
"add",
|
||||
"upstream",
|
||||
"https://gitlab.postmarketos.org/postmarketOS/pmaports.git",
|
||||
],
|
||||
False,
|
||||
)
|
||||
common.run_git(["fetch", "-q", "upstream"])
|
||||
commit = f"upstream/{common.get_upstream_branch()}"
|
||||
if common.run_git(["rev-parse", "HEAD"]) == common.run_git(["rev-parse",
|
||||
commit]):
|
||||
print(f"NOTE: {commit} is on same commit as HEAD, comparing"
|
||||
" HEAD against HEAD~1.")
|
||||
if common.run_git(["rev-parse", "HEAD"]) == common.run_git(["rev-parse", commit]):
|
||||
print(
|
||||
f"NOTE: {commit} is on same commit as HEAD, comparing HEAD against HEAD~1."
|
||||
)
|
||||
commit = "HEAD~1"
|
||||
|
||||
# Exclude linux-next from pkgrel checks, as it is updated automatically.
|
||||
@@ -124,28 +129,35 @@ def check_versions(packages):
|
||||
head = get_package_version(package, "HEAD")
|
||||
upstream = get_package_version(package, commit, False)
|
||||
if not upstream:
|
||||
if head.rpartition('r')[2] != "0":
|
||||
if head.rpartition("r")[2] != "0":
|
||||
print(f"- {package}: {head} (HEAD) (new package) [ERROR]")
|
||||
error = True
|
||||
else:
|
||||
print(f"- {package}: {head} (HEAD) (new package)")
|
||||
continue
|
||||
|
||||
is_device_pkg = os.path.basename(package).startswith('device-')
|
||||
is_device_pkg = os.path.basename(package).startswith("device-")
|
||||
if is_device_pkg:
|
||||
# Check pkgver follows expected format for device packages
|
||||
pkgver = head.rpartition('-r')[0]
|
||||
pkgver = head.rpartition("-r")[0]
|
||||
if not pkgver.isdigit():
|
||||
print(f" - {package}: invalid pkgver \"{pkgver}\""
|
||||
"See: https://docs.postmarketos.org/pmaports/main/packaging-guidelines.html#package-versioning-pkgver-pkgrel")
|
||||
print(
|
||||
f' - {package}: invalid pkgver "{pkgver}"'
|
||||
"See: https://docs.postmarketos.org/pmaports/main/packaging-guidelines.html#package-versioning-pkgver-pkgrel"
|
||||
)
|
||||
error = True
|
||||
|
||||
# Check that pkgrel was reset to 0 when pkgver was changed
|
||||
head_parsed = get_package_contents(package, "HEAD", False)
|
||||
upstream_parsed = get_package_contents(package, commit, False)
|
||||
if head_parsed["pkgver"] != upstream_parsed["pkgver"] and head_parsed["pkgrel"] != "0":
|
||||
print(f" - {package}: pkgrel should be 0 when pkgver changes."
|
||||
"See: https://docs.postmarketos.org/pmaports/main/packaging-guidelines.html#package-versioning-pkgver-pkgrel")
|
||||
if (
|
||||
head_parsed["pkgver"] != upstream_parsed["pkgver"]
|
||||
and head_parsed["pkgrel"] != "0"
|
||||
):
|
||||
print(
|
||||
f" - {package}: pkgrel should be 0 when pkgver changes."
|
||||
"See: https://docs.postmarketos.org/pmaports/main/packaging-guidelines.html#package-versioning-pkgver-pkgrel"
|
||||
)
|
||||
error = True
|
||||
|
||||
# Compare head and upstream versions
|
||||
@@ -169,15 +181,16 @@ if __name__ == "__main__":
|
||||
packages = common.get_changed_packages()
|
||||
if len(packages) == 0:
|
||||
print("no aports changed in this branch")
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
|
||||
print(f"Changed packages: {packages}")
|
||||
|
||||
# Potentially skip this check
|
||||
if common.commit_message_has_string("[ci:skip-vercheck]"):
|
||||
print("WARNING: not checking for changed package versions"
|
||||
" ([ci:skip-vercheck])!")
|
||||
exit(0)
|
||||
print(
|
||||
"WARNING: not checking for changed package versions ([ci:skip-vercheck])!"
|
||||
)
|
||||
sys.exit(0)
|
||||
|
||||
# Initialize args (so we can use pmbootstrap's APKBUILD parsing)
|
||||
sys.argv = ["pmbootstrap.py", "chroot"]
|
||||
@@ -187,7 +200,6 @@ if __name__ == "__main__":
|
||||
# pmb.helpers.logging.init(args)
|
||||
pmb.helpers.logging.init(context.log, args.verbose, context.details_to_stdout)
|
||||
|
||||
|
||||
# Verify package versions
|
||||
print("checking changed package versions...")
|
||||
check_versions(packages)
|
||||
|
||||
@@ -22,7 +22,7 @@ def get_devices() -> list[str]:
|
||||
# devices that have a working mainline kernel. Those are usually
|
||||
# unmaintained and therefore might not appear in the wiki. However,
|
||||
# the main device should be documented (remove the -downstream suffix).
|
||||
device = device.removesuffix('-downstream')
|
||||
device = device.removesuffix("-downstream")
|
||||
|
||||
ret.append(device)
|
||||
return sorted(ret)
|
||||
@@ -30,10 +30,10 @@ def get_devices() -> list[str]:
|
||||
|
||||
def get_wiki_devices_html(path: Path | None) -> dict[str, str]:
|
||||
""":param path: to a local file with the saved content of the devices wiki
|
||||
page or None to download a fresh copy
|
||||
:returns: HTML of the page, split into booting and not booting:
|
||||
{"booting": "<!DOCTYPE HTML>\n<html..."
|
||||
"not_booting": "Not booting</span></h2>\n<p>These..."}"""
|
||||
page or None to download a fresh copy
|
||||
:returns: HTML of the page, split into booting and not booting:
|
||||
{"booting": "<!DOCTYPE HTML>\n<html..."
|
||||
"not_booting": "Not booting</span></h2>\n<p>These..."}"""
|
||||
content = ""
|
||||
if path:
|
||||
# Read file
|
||||
@@ -46,7 +46,7 @@ def get_wiki_devices_html(path: Path | None) -> dict[str, str]:
|
||||
content = f.read().decode("utf-8")
|
||||
|
||||
# Split into booting and not booting
|
||||
split = content.split("<span class=\"mw-headline\" id=\"Non-booting_devices\">")
|
||||
split = content.split('<span class="mw-headline" id="Non-booting_devices">')
|
||||
|
||||
if len(split) != 2:
|
||||
print("*** Failed to parse wiki page")
|
||||
@@ -65,16 +65,18 @@ def get_wiki_renamed_devices_html() -> str:
|
||||
|
||||
def check_device(device: str, html: dict[str, str], is_booting: bool) -> bool:
|
||||
""":param is_booting: require the device to be in the booting section, not
|
||||
just anywhere in the page (i.e. in the not booting
|
||||
table).
|
||||
:returns: True when the device is in the appropriate section."""
|
||||
just anywhere in the page (i.e. in the not booting
|
||||
table).
|
||||
:returns: True when the device is in the appropriate section."""
|
||||
if device in html["booting"]:
|
||||
return True
|
||||
if device in html["not_booting"]:
|
||||
if is_booting:
|
||||
print(device + ": still in 'not booting' section (if this is a"
|
||||
" merge request, your device should be in the booting"
|
||||
" section already)")
|
||||
print(
|
||||
device + ": still in 'not booting' section (if this is a"
|
||||
" merge request, your device should be in the booting"
|
||||
" section already)"
|
||||
)
|
||||
return False
|
||||
return True
|
||||
if device in html["renamed"]:
|
||||
@@ -88,17 +90,27 @@ def check_device(device: str, html: dict[str, str], is_booting: bool) -> bool:
|
||||
def main() -> int:
|
||||
# Parse arguments
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--booting", help="devices must be in the upper table,"
|
||||
" being in the 'not booting' table below is not"
|
||||
" enough (all devices in pmaports main and stable"
|
||||
" branches and should be in the upper table)",
|
||||
action="store_true")
|
||||
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")
|
||||
parser.add_argument(
|
||||
"--booting",
|
||||
help="devices must be in the upper table,"
|
||||
" being in the 'not booting' table below is not"
|
||||
" enough (all devices in pmaports main and stable"
|
||||
" branches and should be in the upper table)",
|
||||
action="store_true",
|
||||
)
|
||||
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()
|
||||
|
||||
html = get_wiki_devices_html(args.path)
|
||||
|
||||
+35
-21
@@ -16,7 +16,7 @@ def get_pmaports_dir():
|
||||
|
||||
|
||||
def run_git(parameters, check=True, stderr=None):
|
||||
""" Run git in the pmaports dir and return the output """
|
||||
"""Run git in the pmaports dir and return the output"""
|
||||
cmd = ["git", "-C", get_pmaports_dir()] + parameters
|
||||
try:
|
||||
return subprocess.check_output(cmd, stderr=stderr).decode()
|
||||
@@ -34,23 +34,25 @@ def commit_message_has_string(needle):
|
||||
|
||||
def all_committed_by_merge_bot():
|
||||
base_commit = get_base_commit()
|
||||
commit_emails = run_git(["log", "--pretty=format:%ce", f"{base_commit}..HEAD"]).splitlines()
|
||||
commit_emails = run_git(
|
||||
["log", "--pretty=format:%ce", f"{base_commit}..HEAD"]
|
||||
).splitlines()
|
||||
bot_email = os.getenv("PMOS_MERGE_BOT_EMAIL", "merge-bot@postmarketos.org")
|
||||
return all(bot_email == ce for ce in commit_emails)
|
||||
|
||||
|
||||
def run_pmbootstrap(parameters):
|
||||
""" Run pmbootstrap with the pmaports dir as --aports """
|
||||
"""Run pmbootstrap with the pmaports dir as --aports"""
|
||||
cmd = ["pmbootstrap", "--aports", get_pmaports_dir()] + parameters
|
||||
subprocess.run(cmd, text=True, check=True)
|
||||
|
||||
|
||||
@cache
|
||||
def get_upstream_branch():
|
||||
""" Use pmaports.cfg from current branch (e.g. "v20.05_fix-ci") and
|
||||
channels.cfg from main to retrieve the upstream branch.
|
||||
"""Use pmaports.cfg from current branch (e.g. "v20.05_fix-ci") and
|
||||
channels.cfg from main to retrieve the upstream branch.
|
||||
|
||||
:returns: branch name, e.g. "v20.05" """
|
||||
:returns: branch name, e.g. "v20.05" """
|
||||
|
||||
# Prefer gitlab CI target branch name if it's set (i.e. running in gitlab CI)
|
||||
if target_branch := os.environ.get("CI_MERGE_REQUEST_TARGET_BRANCH_NAME"):
|
||||
@@ -68,10 +70,11 @@ def get_upstream_branch():
|
||||
channels_cfg_str = run_git(["show", "upstream/main:channels.cfg"])
|
||||
channels_cfg = configparser.ConfigParser()
|
||||
channels_cfg.read_string(channels_cfg_str)
|
||||
assert channel in channels_cfg, \
|
||||
f"Channel '{channel}' from pmaports.cfg in your branch is unknown." \
|
||||
" This appears to be an old branch, consider recreating your change" \
|
||||
assert channel in channels_cfg, (
|
||||
f"Channel '{channel}' from pmaports.cfg in your branch is unknown."
|
||||
" This appears to be an old branch, consider recreating your change"
|
||||
" on top of master."
|
||||
)
|
||||
|
||||
return channels_cfg[channel]["branch_pmaports"]
|
||||
|
||||
@@ -86,8 +89,15 @@ def get_base_commit() -> str:
|
||||
return commit
|
||||
|
||||
# Add a remote pointing to postmarketOS/pmaports
|
||||
run_git(["remote", "add", "upstream",
|
||||
"https://gitlab.postmarketos.org/postmarketOS/pmaports.git"], False)
|
||||
run_git(
|
||||
[
|
||||
"remote",
|
||||
"add",
|
||||
"upstream",
|
||||
"https://gitlab.postmarketos.org/postmarketOS/pmaports.git",
|
||||
],
|
||||
False,
|
||||
)
|
||||
run_git(["fetch", "-q", "upstream"])
|
||||
|
||||
branch_upstream = f"upstream/{get_upstream_branch()}"
|
||||
@@ -109,10 +119,10 @@ def get_base_commit() -> str:
|
||||
|
||||
|
||||
def get_changed_files(removed=False):
|
||||
""" Get all changed files and print them, as well as the branch and the
|
||||
commit that was used for the diff.
|
||||
:param removed: also return removed files (default: True)
|
||||
:returns: set of changed files
|
||||
"""Get all changed files and print them, as well as the branch and the
|
||||
commit that was used for the diff.
|
||||
:param removed: also return removed files (default: True)
|
||||
:returns: set of changed files
|
||||
"""
|
||||
commit = get_base_commit()
|
||||
|
||||
@@ -131,7 +141,9 @@ def get_changed_files(removed=False):
|
||||
return ret
|
||||
|
||||
|
||||
def get_changed_packages(skip_archived: bool = False, keep_dir: bool = False) -> set[str]:
|
||||
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)
|
||||
@@ -141,11 +153,12 @@ def get_changed_packages(skip_archived: bool = False, keep_dir: bool = False) ->
|
||||
# * path with a dot (e.g. .ci/, device/.shared-patches/)
|
||||
# * documentation
|
||||
if (
|
||||
not dirname
|
||||
or file.startswith(".")
|
||||
or "/." in file
|
||||
or skip_archived and dirname.startswith("device/archived")
|
||||
or dirname == "docs"
|
||||
not dirname
|
||||
or file.startswith(".")
|
||||
or "/." in file
|
||||
or skip_archived
|
||||
and dirname.startswith("device/archived")
|
||||
or dirname == "docs"
|
||||
):
|
||||
continue
|
||||
|
||||
@@ -185,6 +198,7 @@ def get_changed_kernels(skip_archived: bool = False):
|
||||
ret += [pkgname]
|
||||
return ret
|
||||
|
||||
|
||||
def get_changed_devices(skip_archived: bool = False):
|
||||
ret = []
|
||||
for pkgname in get_changed_packages(skip_archived):
|
||||
|
||||
@@ -12,7 +12,7 @@ import common
|
||||
if __name__ == "__main__":
|
||||
if common.commit_message_has_string("[ci:skip-dint]"):
|
||||
print("WARNING: not linting deviceinfo files ([ci:skip-dint])")
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
|
||||
if "deviceinfo_schema.toml" in common.get_changed_files():
|
||||
print("deviceinfo_schema.toml changed -> checking all deviceinfo files")
|
||||
@@ -20,8 +20,11 @@ if __name__ == "__main__":
|
||||
deviceinfo_files = set(glob.glob(pmaports_dir + "/device/*/*/deviceinfo"))
|
||||
else:
|
||||
# only lint deviceinfo files in the devices repo
|
||||
deviceinfo_files = {file for file in common.get_changed_files()
|
||||
if os.path.basename(file) == "deviceinfo" and file.startswith("device/")}
|
||||
deviceinfo_files = {
|
||||
file
|
||||
for file in common.get_changed_files()
|
||||
if os.path.basename(file) == "deviceinfo" and file.startswith("device/")
|
||||
}
|
||||
|
||||
try:
|
||||
subprocess.run(["dint", "check", *deviceinfo_files], text=True, check=True)
|
||||
|
||||
@@ -38,7 +38,7 @@ class Device:
|
||||
fragment_path = self.full_path / "gitlab-ci.yml.j2"
|
||||
try:
|
||||
fragment_tmpl = fragment_path.read_text()
|
||||
except Exception:
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
return Template(fragment_tmpl).render(device=self)
|
||||
@@ -47,8 +47,10 @@ class Device:
|
||||
def pmaports_path(self) -> Path:
|
||||
# Find the root of pmaports
|
||||
pmaports_root = self.full_path.parent
|
||||
while (not (pmaports_root / "pmaports.cfg").exists() and
|
||||
pmaports_root != pmaports_root.root):
|
||||
while (
|
||||
not (pmaports_root / "pmaports.cfg").exists()
|
||||
and pmaports_root != pmaports_root.root
|
||||
):
|
||||
pmaports_root = pmaports_root.parent
|
||||
assert pmaports_root != pmaports_root.root
|
||||
|
||||
@@ -60,11 +62,11 @@ class Device:
|
||||
|
||||
@property
|
||||
def pkgname(self) -> str:
|
||||
return self.apkbuild['pkgname']
|
||||
return self.apkbuild["pkgname"]
|
||||
|
||||
@property
|
||||
def arch(self) -> Arch:
|
||||
return Arch(self.apkbuild['arch'][0])
|
||||
return Arch(self.apkbuild["arch"][0])
|
||||
|
||||
@property
|
||||
def testing_dependencies(self) -> set[str]:
|
||||
@@ -88,7 +90,7 @@ class Device:
|
||||
kernels = []
|
||||
|
||||
subpackage_prefix = f"device-{self.codename}-kernel-"
|
||||
for subpkgname in self.apkbuild.get('subpackages', []):
|
||||
for subpkgname in self.apkbuild.get("subpackages", []):
|
||||
if not subpkgname.startswith(subpackage_prefix):
|
||||
continue
|
||||
kernel_name = subpkgname.removeprefix(subpackage_prefix)
|
||||
@@ -129,7 +131,7 @@ class Device:
|
||||
continue
|
||||
|
||||
supported_devices[dev.pmaports_path] = dev
|
||||
except Exception:
|
||||
except FileNotFoundError:
|
||||
traceback.print_exc()
|
||||
return supported_devices
|
||||
|
||||
@@ -138,17 +140,23 @@ class ArchTagSet(set):
|
||||
def update(self, iterable):
|
||||
supported_arches = Arch.supported_binary()
|
||||
# This ignores things like !armv7, that could be a follow-up optimization
|
||||
if 'noarch' in iterable or 'all' in iterable:
|
||||
if "noarch" in iterable or "all" in iterable:
|
||||
iterable = [arch for arch in supported_arches]
|
||||
super().update([Arch(arch) for arch in iterable if Arch(arch) in supported_arches])
|
||||
super().update(
|
||||
[Arch(arch) for arch in iterable if Arch(arch) in supported_arches]
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
)
|
||||
parser.add_argument("--template", default=".ci/build-jobs.yaml.j2", help="Jinja2 input template")
|
||||
parser.add_argument("--output", default=".ci/build-jobs.yaml", help="output pipeline")
|
||||
parser.add_argument(
|
||||
"--template", default=".ci/build-jobs.yaml.j2", help="Jinja2 input template"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--output", default=".ci/build-jobs.yaml", help="output pipeline"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# pmb logging has to be initialized for later pmb commands to work, setting
|
||||
@@ -179,13 +187,13 @@ if __name__ == "__main__":
|
||||
if path.name != "APKBUILD":
|
||||
continue
|
||||
apkbuild = pmb.parse.apkbuild(path)
|
||||
packages_modified.add(apkbuild['pkgname'])
|
||||
packages_modified.add(apkbuild["pkgname"])
|
||||
archs.update(apkbuild["arch"])
|
||||
|
||||
# Add all the devices found in CI that depend on the package that got
|
||||
# modified
|
||||
for device in supported_devices.values():
|
||||
if apkbuild['pkgname'] in device.dependencies:
|
||||
if apkbuild["pkgname"] in device.dependencies:
|
||||
devices_under_test.add(device)
|
||||
|
||||
if common.commit_message_has_string("[ci:skip-build]"):
|
||||
|
||||
+14
-10
@@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Same dir
|
||||
import common
|
||||
@@ -12,10 +13,11 @@ def check_kconfig(pkgnames):
|
||||
last_failed = None
|
||||
for i in range(len(pkgnames)):
|
||||
pkgname = pkgnames[i]
|
||||
print(f" ({i+1}/{len(pkgnames)}) {pkgname}")
|
||||
print(f" ({i + 1}/{len(pkgnames)}) {pkgname}")
|
||||
|
||||
p = subprocess.run(["pmbootstrap", "kconfig", "check", "--keep-going", pkgname],
|
||||
check=False)
|
||||
p = subprocess.run(
|
||||
["pmbootstrap", "kconfig", "check", "--keep-going", pkgname], check=False
|
||||
)
|
||||
|
||||
if p.returncode:
|
||||
last_failed = pkgname
|
||||
@@ -32,8 +34,10 @@ def show_error(last_failed):
|
||||
print()
|
||||
print("---")
|
||||
print()
|
||||
print("Please adjust your kernel config. This is required for getting your"
|
||||
" patch merged.")
|
||||
print(
|
||||
"Please adjust your kernel config. This is required for getting your"
|
||||
" patch merged."
|
||||
)
|
||||
print()
|
||||
print("Edit your kernel config:")
|
||||
print(f" pmbootstrap kconfig edit {last_failed}")
|
||||
@@ -76,21 +80,21 @@ if __name__ == "__main__":
|
||||
print("kconfigcheck.toml changed -> checking all kernels")
|
||||
if not check_kconfig_all():
|
||||
show_error_all()
|
||||
exit(1)
|
||||
exit(0)
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
|
||||
pkgnames = common.get_changed_kernels(skip_archived=True)
|
||||
print(f"Changed kernels: {pkgnames}")
|
||||
|
||||
if len(pkgnames) == 0:
|
||||
print("No kernels changed in this branch")
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
elif common.commit_message_has_string("[ci:skip-kconfigcheck]"):
|
||||
print("WARNING: not checking kernel configs ([ci:skip-kconfigcheck])")
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
|
||||
last_failed = check_kconfig(pkgnames)
|
||||
|
||||
if last_failed:
|
||||
show_error(last_failed)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -19,8 +19,9 @@ def verify_checksums(packages):
|
||||
|
||||
print("verifying checksums: " + ", ".join(packages))
|
||||
common.run_pmbootstrap(["build_init"])
|
||||
common.run_pmbootstrap(["--details-to-stdout", "checksum", "--verify"] +
|
||||
list(packages))
|
||||
common.run_pmbootstrap(
|
||||
["--details-to-stdout", "checksum", "--verify"] + list(packages)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -39,14 +40,14 @@ if __name__ == "__main__":
|
||||
archived = set()
|
||||
for path in pmb.core.pkgrepo.pkgrepo_iter_package_dirs():
|
||||
# Store archived packages for matching later
|
||||
if os.path.split(os.path.split(path)[0])[1] == 'archived':
|
||||
if os.path.split(os.path.split(path)[0])[1] == "archived":
|
||||
archived.add(os.path.basename(path))
|
||||
continue
|
||||
buildable_pkgs.add(os.path.basename(path))
|
||||
|
||||
# To store a list of packages from extra-repos/systemd for special handling
|
||||
# later:
|
||||
systemd_pkgs = list()
|
||||
systemd_pkgs = []
|
||||
|
||||
# Filter out packages are not found in enabled repos or are in archived
|
||||
# (Iterate over copy of packages, because we modify it in this loop)
|
||||
@@ -73,7 +74,7 @@ if __name__ == "__main__":
|
||||
if len(packages) == 0:
|
||||
print("no packages to check for the current repo")
|
||||
else:
|
||||
verify_checksums(packages)
|
||||
verify_checksums(packages)
|
||||
|
||||
# FIXME: this should probably be more generic, if other repos are added later?
|
||||
if systemd_pkgs:
|
||||
|
||||
Reference in New Issue
Block a user