CI: Add a test that parses all rawhide pyproject specs with rpm --specfile

Downloads rpm-specs-latest.tar.xz, finds all specs using %pyproject
macros, and runs rpm --specfile on each to verify they parse without
errors. Only runs on rawhide as the spec files are rawhide only.

Assisted-By: Claude Opus 4.6
(cherry picked from Fedora commit 83cc2c14ea)
This commit is contained in:
Miro Hrončok 2026-05-08 01:24:04 +02:00
parent b2145641c0
commit fc1e0fc32f
2 changed files with 78 additions and 0 deletions

View File

@ -123,6 +123,13 @@ discover:
- name: mistune_312
path: /tests
test: ./mocktest.sh python-mistune --define 'python3_pkgversion 3.12'
- name: rawhide_specs
how: shell
when: distro == fedora-rawhide
tests:
- name: rpm_specfile_check
path: /tests
test: ./test-rpm-specs-parse.sh
prepare:
- name: Install dependencies
how: install

71
tests/test-rpm-specs-parse.sh Executable file
View File

@ -0,0 +1,71 @@
#!/usr/bin/bash -eu
# Download all Fedora rawhide spec files and verify that every spec using
# %%pyproject macros parses successfully with rpm --specfile.
workdir=$(mktemp -d)
trap 'rm -rf $workdir' EXIT
curl -L https://pkgs.fedoraproject.org/repo/rpm-specs-latest.tar.xz | tar -xJf - -C "$workdir"
specs=$(grep -rl '%pyproject' "$workdir"/rpm-specs/ --include='*.spec' || true)
if [ -z "$specs" ]; then
echo "ERROR: No specs with %%pyproject found" >&2
exit 1
fi
nspecs=$(echo "$specs" | wc -l)
echo "Found $nspecs specfiles with %pyproject macros"
# Known-broken spec filenames that should not cause test failure
allowlist=(
# "broken-package.spec"
)
is_allowed() {
local base
base=$(basename "$1")
for a in "${allowlist[@]}"; do
if [ "$base" = "$a" ]; then
return 0
fi
done
return 1
}
total=0
failed=0
failed_specs=()
last_pct=-1
for spec in $specs; do
total=$((total + 1))
pct=$((total * 100 / nspecs))
if [ $pct -ne $last_pct ]; then
printf '\r%d%% done (%d/%d)' "$pct" "$total" "$nspecs" >&2
last_pct=$pct
fi
if ! output=$(LANG=C.utf-8 rpm --specfile "$spec" 2>&1); then
if is_allowed "$spec"; then
printf '\r\033[K' >&2
echo "SKIP (allowlisted): $spec"
else
printf '\r\033[K' >&2
echo "FAIL: $spec"
echo "$output" | head -20
echo "---"
failed=$((failed + 1))
failed_specs+=("$spec")
fi
fi
done
printf '\r\033[K' >&2
echo "Tested $total specs, $failed failures"
if [ $failed -gt 0 ]; then
echo ""
echo "Failed specs:"
printf ' %s\n' "${failed_specs[@]}"
exit 1
fi