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
This commit is contained in:
parent
2acda15168
commit
83cc2c14ea
7
plan.fmf
7
plan.fmf
@ -115,6 +115,13 @@ discover:
|
||||
- name: isort_c10s
|
||||
path: /tests
|
||||
test: ID=centos VERSION_ID=10 ./mocktest.sh python-isort
|
||||
- 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
71
tests/test-rpm-specs-parse.sh
Executable 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
|
||||
Loading…
Reference in New Issue
Block a user