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.
38 lines
1.4 KiB
Shell
Executable file
38 lines
1.4 KiB
Shell
Executable file
#!/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"
|