|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +# Copyright Contributors to the Packit project. |
| 4 | +# SPDX-License-Identifier: MIT |
| 5 | + |
| 6 | +# /// script |
| 7 | +# dependencies = [ |
| 8 | +# "ruamel.yaml", |
| 9 | +# "requests", |
| 10 | +# ] |
| 11 | +# /// |
| 12 | + |
| 13 | +import copy |
| 14 | + |
| 15 | +import requests |
| 16 | +import ruamel.yaml |
| 17 | +from pathlib import Path |
| 18 | + |
| 19 | +# Constants |
| 20 | +ZUUL_YAML = "https://pagure.io/fedora-project-config/raw/master/f/resources/fedora-distgits.yaml" |
| 21 | +SCRIPTS_DIR = Path(__file__).parent |
| 22 | +ROOT_DIR = SCRIPTS_DIR.parent |
| 23 | +packit_service_file = ROOT_DIR / "secrets/packit/prod/packit-service.yaml.j2" |
| 24 | +SKIP_JINJA_LINES = 32 |
| 25 | +DIST_GIT_FORMAT = r"https://src.fedoraproject.org/rpms/{}" |
| 26 | + |
| 27 | +MAILING_LIST_ANNOUNCEMENT = """ |
| 28 | +Dear package maintainers currently using Zuul, |
| 29 | +
|
| 30 | +Packit as Fedora dist-git CI has recently reached feature-parity with the Zuul CI, and as the first step |
| 31 | +in the final phase implementation of the "Packit as dist-git CI" change [1] we are migrating |
| 32 | +the current Zuul CI users to packit Fedora CI [2] and disabling the Zuul runners on |
| 33 | +src.fedoraproject.org/rpms/* for the time being. |
| 34 | +
|
| 35 | +Our plan is to automatically migrate the Zuul dist-git packages on 2026-01-12 (January 12). |
| 36 | +Please let us know of any concerns you might have with the migration up until then so we can decide whether |
| 37 | +we can go forward with it. We will send another reminder of this as a reply to this announcement one week |
| 38 | +before the migration 2026-01-05 (January 5). |
| 39 | +
|
| 40 | +After the packages are migrated we will monitor your feedback [3-6] on this migration and decide if we can go ahead |
| 41 | +with the Zuul deprecation and disablement or need to resolve any blocking issues first. We could also keep the |
| 42 | +Zuul CI temporarily running on a small subset of packages if requested. |
| 43 | +
|
| 44 | +We are looking forward to your feedback on this matter. |
| 45 | +
|
| 46 | +PS: The migration of the other Zuul jobs that are linked to pagure.io [7] will be addressed at a later |
| 47 | +time as these require custom handling and are tied with the forge migration. We do not have a timeline |
| 48 | +for this part yet, but we will provide an update as soon as we have a plan for this. |
| 49 | +
|
| 50 | +[1]: https://fedoraproject.org/wiki/Changes/PackitDistgitCI |
| 51 | +[2]: https://github.com/packit/deployment/pull/672 |
| 52 | +[3]: Fedora CI channel https://matrix.to/#/#fedora-ci:fedoraproject.org |
| 53 | +[4]: Packit channel https://matrix.to/#/#packit:fedora.im |
| 54 | +[5]: Packit issues https://github.com/packit/packit-service/issues/new?template=fedora-ci.yml |
| 55 | +[6]: This email and discussion thread |
| 56 | +[7]: https://pagure.io/fedora-project-config/blob/master/f/resources/fedora-sources.yaml |
| 57 | +""" |
| 58 | + |
| 59 | +# Using ruamel.yaml to preserve comments and format |
| 60 | +packit_service_yaml = ruamel.yaml.YAML() |
| 61 | +packit_service_yaml.indent(mapping=2, sequence=4, offset=2) |
| 62 | + |
| 63 | +# Get the current projects subscribed to zuul |
| 64 | +response = requests.get(ZUUL_YAML) |
| 65 | +fedora_dstgits = ruamel.yaml.YAML().load(response.content) |
| 66 | +zuul_projects = [ |
| 67 | + list(item.keys())[0].removeprefix("rpms/") |
| 68 | + for item in fedora_dstgits["resources"]["projects"]["Fedora-Distgits"][ |
| 69 | + "source-repositories" |
| 70 | + ] |
| 71 | +] |
| 72 | + |
| 73 | +# Get the current packit-service.yaml.j2 file |
| 74 | +with packit_service_file.open("r") as f: |
| 75 | + jinja_lines = [] |
| 76 | + for _ in range(SKIP_JINJA_LINES): |
| 77 | + jinja_lines.append(next(f)) |
| 78 | + packit_service = packit_service_yaml.load(f.read()) |
| 79 | + |
| 80 | +# Onboard all the missing users |
| 81 | +fedora_ci_projects = copy.copy(packit_service["enabled_projects_for_fedora_ci"]) |
| 82 | +previous_count = len(fedora_ci_projects) |
| 83 | +for project in zuul_projects: |
| 84 | + dist_git_url = DIST_GIT_FORMAT.format(project) |
| 85 | + if dist_git_url not in fedora_ci_projects: |
| 86 | + fedora_ci_projects.append(dist_git_url) |
| 87 | +new_count = len(fedora_ci_projects) |
| 88 | + |
| 89 | +# Update the packit-service.yaml.j2 file |
| 90 | +print(f"Number of projects added: {new_count - previous_count}") |
| 91 | +packit_service["enabled_projects_for_fedora_ci"] = sorted(fedora_ci_projects) |
| 92 | +with packit_service_file.open("w") as f: |
| 93 | + for line in jinja_lines: |
| 94 | + f.write(line) |
| 95 | + packit_service_yaml.dump(packit_service, f) |
0 commit comments