name: Validate Fedora x86_64-v3 Copr SRPMs (Gitea) on: workflow_dispatch: inputs: package_input: description: "Optional comma, space, or newline separated package list. Leave blank to use packages.txt." required: false default: "" type: string push: paths: - '.copr/Makefile' - '.gitea/workflows/build-v3-rpms.yml' - 'ci/copr-distgit-make-srpm.py' - 'packages.txt' - 'packaging/copr-rpm-macros-x86-64-v3.spec' jobs: prepare: runs-on: ubuntu-latest outputs: matrix: ${{ steps.select.outputs.matrix }} package_count: ${{ steps.select.outputs.package_count }} steps: - uses: actions/checkout@v4 - id: select env: PACKAGE_INPUT: ${{ inputs.package_input }} run: | python3 <<'PY' import json import os import re from pathlib import Path packages_file = Path("packages.txt") package_input = os.environ.get("PACKAGE_INPUT", "") if not package_input.strip() and not packages_file.exists(): print("packages.txt not found") raise SystemExit(1) if package_input.strip(): packages = [ entry for entry in re.split(r"[\s,]+", package_input.strip()) if entry ] else: packages = [ line.strip() for line in packages_file.read_text(encoding="utf-8").splitlines() if line.strip() and not line.startswith("#") ] max_matrix = 128 matrix = [] if packages: shard_size = max(1, -(-len(packages) // max_matrix)) shards = [ packages[index:index + shard_size] for index in range(0, len(packages), shard_size) ] matrix = [ { "shard_label": f"{shard_index + 1:03d}", "packages": shard, } for shard_index, shard in enumerate(shards) ] with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as handle: handle.write(f"matrix={json.dumps(matrix)}\n") handle.write(f"package_count={len(packages)}\n") PY validate-srpms: needs: prepare if: ${{ needs.prepare.outputs.package_count != '0' }} runs-on: ubuntu-latest container: image: fedora:43 strategy: fail-fast: false matrix: include: ${{ fromJSON(needs.prepare.outputs.matrix) }} steps: - uses: actions/checkout@v4 - name: Install SRPM validation tools run: | dnf -y install git make python3 rpm-build ca-certificates curl - name: Generate shard SRPMs env: PACKAGES_JSON: ${{ toJSON(matrix.packages) }} SHARD_LABEL: ${{ matrix.shard_label }} run: | python3 <<'PY' import json import os import subprocess from pathlib import Path workspace = Path(os.environ["GITHUB_WORKSPACE"]) outdir = workspace / "artifacts" / f"srpm-shard-{os.environ['SHARD_LABEL']}" outdir.mkdir(parents=True, exist_ok=True) subprocess.run( [ "make", "-f", ".copr/Makefile", "srpm", f"outdir={outdir}", "spec=packaging/copr-rpm-macros-x86-64-v3.spec", ], check=True, cwd=workspace, ) for package_name in json.loads(os.environ["PACKAGES_JSON"]): subprocess.run( [ "make", "-f", ".copr/Makefile", "srpm", f"outdir={outdir}", f"spec={package_name}", ], check=True, cwd=workspace, ) PY