From 3672bbd10c5844c0ee7163add5e26d84251423e0 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: Mar 28 2024 17:09:49 +0000 Subject: [PATCH 1/3] comps-sync.py: Return non-zero if changes are needed but not saved This will let us use that in CI to check for pending comps-sync changes. --- diff --git a/comps-sync.py b/comps-sync.py index 75f610e..664a55f 100755 --- a/comps-sync.py +++ b/comps-sync.py @@ -1,10 +1,14 @@ #!/usr/bin/python3 ''' -Usage: ./comps-sync.py /path/to/comps-f41.xml.in +Usage: ./comps-sync.py [--save] /path/to/comps-f41.xml.in -Can both remove packages from the manifest which are not mentioned in comps, -and add packages from comps. +Filter and sync packages from comps groups into rpm-ostree manifests. The sync +will remove packages from the manifests which are not mentioned in comps and +add missing packages from comps to the manifests. + +Use --save to write the changes and always exit with a 0 return code. +Otherwise, exit with a non zero return code if any changes are needed. ''' import argparse @@ -148,15 +152,18 @@ def update_manifests_from_groups(comps, groups, path, desktop, save, comps_exclu manifest_packages[arch].add(pkg) print(' + {} ({}, groups: {}, arches: {})'.format(pkg, format_pkgtype(req), ', '.join(groups), ', '.join(arches))) - if (n_manifest_new > 0 or n_comps_new > 0) and save: - if desktop == "common": - write_manifest(path, manifest_packages) - else: - write_manifest(path, manifest_packages, include="fedora-common-ostree.yaml") + if (n_manifest_new > 0 or n_comps_new > 0): + if save: + if desktop == "common": + write_manifest(path, manifest_packages) + else: + write_manifest(path, manifest_packages, include="fedora-common-ostree.yaml") + return 1 + return 0 def main(): parser = argparse.ArgumentParser() - parser.add_argument("--save", help="Write changes", action='store_true') + parser.add_argument("--save", help="Write changes to manifests", action='store_true') parser.add_argument("src", help="Source path") args = parser.parse_args() @@ -184,7 +191,10 @@ def main(): # Always include the packages from the workstation-ostree-support group groups.append('workstation-ostree-support') - update_manifests_from_groups(comps, groups, 'fedora-common-ostree-pkgs.yaml', "common", args.save, comps_exclude_list, comps_exclude_list_all) + # Return code indicates if changes have or would have been done + ret = 0 + + ret += update_manifests_from_groups(comps, groups, 'fedora-common-ostree-pkgs.yaml', "common", args.save, comps_exclude_list, comps_exclude_list_all) # List of comps groups used for each desktop desktops_comps_groups = { @@ -202,7 +212,10 @@ def main(): # Generate treefiles for all desktops for desktop, groups in desktops_comps_groups.items(): print() - update_manifests_from_groups(comps, groups, f'{desktop}-desktop-pkgs.yaml', desktop, args.save, comps_desktop_exclude_list, comps_exclude_list_all) + ret += update_manifests_from_groups(comps, groups, f'{desktop}-desktop-pkgs.yaml', desktop, args.save, comps_desktop_exclude_list, comps_exclude_list_all) + + if not args.save and ret != 0: + sys.exit(1) if __name__ == "__main__": main() From abd2d7c6df4da328c8f6cc9be601ef88d5385803 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: Mar 28 2024 17:10:27 +0000 Subject: [PATCH 2/3] justfile: Add a recipe to check for comps sync changes Will be used by Zuul CI. --- diff --git a/justfile b/justfile index 1277b67..90046f8 100644 --- a/justfile +++ b/justfile @@ -71,6 +71,24 @@ comps-sync: version="$(rpm-ostree compose tree --print-only --repo=repo fedora-${default_variant}.yaml | jq -r '."mutate-os-release"')" ./comps-sync.py --save fedora-comps/comps-f${version}.xml.in +# Check if the manifests are in sync with the content of the comps groups +comps-sync-check: + #!/bin/bash + set -euo pipefail + + if [[ ! -d fedora-comps ]]; then + git clone https://pagure.io/fedora-comps.git + else + pushd fedora-comps > /dev/null || exit 1 + git fetch + git reset --hard origin/main + popd > /dev/null || exit 1 + fi + + default_variant={{default_variant}} + version="$(rpm-ostree compose tree --print-only --repo=repo fedora-${default_variant}.yaml | jq -r '."mutate-os-release"')" + ./comps-sync.py fedora-comps/comps-f${version}.xml.in + # Output the processed manifest for a given variant (defaults to Silverblue) manifest variant=default_variant: #!/bin/bash From fd6487c95f22c0348f8aab0053be8ec0d7b646c7 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: Apr 04 2024 08:17:34 +0000 Subject: [PATCH 3/3] zuul: Verify that the comps and manifests are synced Best effort (as it will only run on PRs) check for comps / manifests sync. --- diff --git a/ci/validate.yaml b/ci/validate.yaml index b07f753..84d21e3 100644 --- a/ci/validate.yaml +++ b/ci/validate.yaml @@ -17,6 +17,13 @@ chdir: "{{ zuul.project.src_dir }}" cmd: just validate + - name: Verify that the comps and manifests are synced + ansible.builtin.shell: + chdir: "{{ zuul.project.src_dir }}" + cmd: "just validate comps-sync-check && touch .zuulci.comps" + # Still run the next step if this one fails + ignore_errors: true + - name: Perform dependency resolution for Silverblue ansible.builtin.shell: chdir: "{{ zuul.project.src_dir }}" @@ -53,4 +60,4 @@ - name: Check if any previous dependency resolution steps failed ansible.builtin.shell: chdir: "{{ zuul.project.src_dir }}" - cmd: "[[ -f .zuulci.silverblue ]] && [[ -f .zuulci.kinoite ]] && [[ -f .zuulci.sericea ]] && [[ -f .zuulci.onyx ]]" + cmd: "[[ -f .zuulci.comps ]] && [[ -f .zuulci.silverblue ]] && [[ -f .zuulci.kinoite ]] && [[ -f .zuulci.sericea ]] && [[ -f .zuulci.onyx ]]"