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:
parent
cead194b2a
commit
d3e15c7fbe
1 changed files with 96 additions and 26 deletions
38
scripts/check-vm-test-list.sh
Executable file
38
scripts/check-vm-test-list.sh
Executable 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"
|
||||
Loading…
Reference in a new issue