Watch
0
0
Fork
You've already forked hyperhive
0

vm-nightly: one job per test, with a lint that keeps the matrix list in step

A stuck test in the shared job was cut at the runner's one-hour limit and hid the other tests' results. The matrix list is static; check-vm-test-list.sh fails CI when it differs from nix/vm-tests.nix.
This commit is contained in:
atlas 2026-11-19 11:39:38 +01:00 • committed by mara
commit d3e15c7fbe
2 changed files with 96 additions and 26 deletions

38
scripts/check-vm-test-list.sh Executable file
View file

@ -0,0 +1,38 @@
#!/bin/sh
# CI lint: the `test` matrix in vm-nightly.yml must list exactly the
# attributes of `nix/vm-tests.nix`. The matrix is static, so a test missing
# from it never runs nightly and a stale entry fails its job.
set -eu
workflow=".forgejo/workflows/vm-nightly.yml"
tests_nix="nix/vm-tests.nix"
declared="$(sed -n 's/^ \([A-Za-z0-9_-][A-Za-z0-9_-]*\) = import .*/\1/p' "$tests_nix" | sort)"
listed="$(awk '
/^ test:$/ { inlist = 1; next }
inlist && /^ - / { sub(/^ - /, ""); print; next }
inlist { inlist = 0 }
' "$workflow" | sort)"
if [ -z "$declared" ]; then
echo "::error file=$tests_nix::no test attributes found; the extraction pattern no longer matches the file" >&2
exit 1
fi
if [ -z "$listed" ]; then
echo "::error file=$workflow::no matrix entries found under 'test:'; the extraction pattern no longer matches the file" >&2
exit 1
fi
if [ "$declared" != "$listed" ]; then
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
echo "$declared" >"$work/declared"
echo "$listed" >"$work/listed"
echo "::error file=$workflow::matrix test list differs from $tests_nix" >&2
echo "only in $tests_nix:" >&2
comm -23 "$work/declared" "$work/listed" >&2
echo "only in $workflow:" >&2
comm -13 "$work/declared" "$work/listed" >&2
exit 1
fi
echo "vm-nightly matrix lists all $(echo "$declared" | wc -l) tests of $tests_nix"

View file

@ -45,5 +45,11 @@ if ! sh "$repo_root/scripts/check-dashboard-service-names.sh"; then
exit 1
fi
echo "pre-push: running vm-test-list lint..." >&2
if ! sh "$repo_root/scripts/check-vm-test-list.sh"; then
echo "pre-push: vm-test-list lint FAILED — fix before pushing" >&2
exit 1
fi
echo "pre-push: lints passed ✓" >&2
exit 0