From 5b0a3031afd988ff4a11d7e789289f0619f9b2e9 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Wed, 28 Oct 2026 05:38:08 -0500 Subject: [PATCH] ci(id): guard crash-gate PR partition against uncovered ignored tests (#1635) --- .github/scripts/check-crash-gate-coverage.sh | 117 +++++++++++++++++++ .github/scripts/check-id-pr-checks.sh | 4 + .github/workflows/id-check.yml | 8 ++ pkgs/id/justfile | 4 + 4 files changed, 133 insertions(+) create mode 100755 .github/scripts/check-crash-gate-coverage.sh diff --git a/.github/scripts/check-crash-gate-coverage.sh b/.github/scripts/check-crash-gate-coverage.sh new file mode 100755 index 0000000000..21b99a7a83 --- /dev/null +++ b/.github/scripts/check-crash-gate-coverage.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash +# Guard the crash-gate PR partition against silent coverage loss (#1635). +# +# PR #1310 split the aggregate `crash-gate` recipe into four PR checks +# partitioned by test-name filter (pkgs/id/justfile): crash-gate-sampled +# runs WITHOUT --include-ignored, and crash-gate-sweep / -control / +# -ingest each run exactly ONE `--include-ignored ` filter. +# An #[ignore]d test in pkgs/id/tests/crash/ therefore gets PR coverage +# only if its name contains one of those substrings; the partition is +# complete today but nothing checked it, so a future ignored crash test +# matching no split would silently run in no PR check at all — only the +# nightly aggregate would ever execute it. +# +# This script makes the partition a checked invariant, at source level +# (no cargo build, so it can run in the id-check.yml guard job): +# +# 1. enumerate the #[ignore]d test names in pkgs/id/tests/crash/*.rs +# 2. subtract the named corpus-writer exclusions below — they rewrite +# the checked-in corpus files and are run by hand, never in CI +# 3. extract the split filters from the justfile's crash-gate-sweep / +# -control / -ingest recipes +# 4. fail, naming each test, when an ignored gate test contains none +# of the filter substrings +# +# Parse drift is a failure too: finding no filters or no ignored tests +# means the inputs changed shape, and a guard that silently passes on +# empty input is the failure this script exists to prevent. +set -euo pipefail + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +crash_dir="$repo_root/pkgs/id/tests/crash" +justfile="$repo_root/pkgs/id/justfile" + +excluded=(write_corpus write_corpus_identity) + +# --- split filters from the justfile recipes ------------------------------- +filters=() +for recipe in crash-gate-sweep crash-gate-control crash-gate-ingest; do + filter="$( + awk -v header="^${recipe}:" ' + $0 ~ header { in_recipe = 1; next } + in_recipe && /--include-ignored/ { + for (i = 1; i <= NF; i++) { + if ($i == "--include-ignored") { print $(i + 1); exit } + } + } + ' "$justfile" + )" + if [[ -z $filter ]]; then + echo "::error::check-crash-gate-coverage: no --include-ignored filter found in the '$recipe' recipe in pkgs/id/justfile — the guard cannot verify the partition; update the recipe or this script." + exit 1 + fi + filters+=("$filter") +done + +# --- #[ignore]d test names from the crash suite ---------------------------- +# An ignored test is declared as a #[ignore ...] attribute line followed +# (after any further attribute/doc lines) by `fn (`. Names repeat +# across files (main.rs and identity.rs carry copies); coverage is by +# name, so deduplicate. +ignored_tests="$( + awk ' + /#\[ignore/ { ignored = 1; next } + ignored && /^#\[/ { next } + ignored && /^\/\/\// { next } + ignored && /^fn [A-Za-z0-9_]+/ { + name = $2 + sub(/\(.*/, "", name) + print name + ignored = 0 + next + } + ignored { ignored = 0 } + ' "$crash_dir"/*.rs | sort -u +)" + +if [[ -z $ignored_tests ]]; then + echo "::error::check-crash-gate-coverage: no #[ignore]d tests found in pkgs/id/tests/crash/*.rs — the suite changed shape; update this guard." + exit 1 +fi + +# --- coverage ---------------------------------------------------------------- +uncovered=() +covered=0 +while IFS= read -r name; do + skip=0 + for ex in "${excluded[@]}"; do + if [[ $name == "$ex" ]]; then + skip=1 + break + fi + done + if [[ $skip -eq 1 ]]; then + continue + fi + hit=0 + for filter in "${filters[@]}"; do + if [[ $name == *"$filter"* ]]; then + hit=1 + break + fi + done + if [[ $hit -eq 1 ]]; then + covered=$((covered + 1)) + else + uncovered+=("$name") + fi +done <<<"$ignored_tests" + +if [[ ${#uncovered[@]} -ne 0 ]]; then + for name in "${uncovered[@]}"; do + echo "::error::#[ignore]d crash test '$name' matches none of the crash-gate PR split filters (${filters[*]}) — it would run in no PR check. Rename it to contain a split filter, extend a split in pkgs/id/justfile, or add it to the exclusion list in check-crash-gate-coverage.sh if it is a corpus writer." + done + exit 1 +fi + +echo "crash-gate partition covers all $covered #[ignore]d gate tests (${#excluded[@]} corpus writers excluded: ${excluded[*]})." diff --git a/.github/scripts/check-id-pr-checks.sh b/.github/scripts/check-id-pr-checks.sh index 51592dc370..2dbdcf66ee 100755 --- a/.github/scripts/check-id-pr-checks.sh +++ b/.github/scripts/check-id-pr-checks.sh @@ -20,6 +20,10 @@ # The aggregate `crash-gate` is likewise covered by composition on # PRs: crash-gate-sampled/-sweep/-control/-ingest partition its tests # by name filter (#551). They still run in the nightly full flake check. +# That partition is a checked invariant, not just prose: +# check-crash-gate-coverage.sh runs in the same guard job and fails, +# naming the test, when an #[ignore]d crash test matches none of the +# split filters (#1635). # # Usage: check-id-pr-checks.sh [list-file] # For tests, ID_FLAKE_CHECKS_FILE names a file with one flake check diff --git a/.github/workflows/id-check.yml b/.github/workflows/id-check.yml index 1d1032ff32..60eabf8e49 100644 --- a/.github/workflows/id-check.yml +++ b/.github/workflows/id-check.yml @@ -47,12 +47,14 @@ on: - ".github/workflows/id-check.yml" - ".github/scripts/id-pr-checks.txt" - ".github/scripts/check-id-pr-checks.sh" + - ".github/scripts/check-crash-gate-coverage.sh" pull_request: paths: - "pkgs/id/**" - ".github/workflows/id-check.yml" - ".github/scripts/id-pr-checks.txt" - ".github/scripts/check-id-pr-checks.sh" + - ".github/scripts/check-crash-gate-coverage.sh" permissions: contents: read @@ -93,6 +95,12 @@ jobs: - name: Guard PR check list against flake drift run: .github/scripts/check-id-pr-checks.sh + # The crash-gate composition asserted in check-id-pr-checks.sh is + # itself checked (#1635): an #[ignore]d crash test matching none + # of the PR split filters fails here by name. + - name: Guard crash-gate PR partition coverage + run: .github/scripts/check-crash-gate-coverage.sh + - name: Emit PR check list for the matrix id: list run: | diff --git a/pkgs/id/justfile b/pkgs/id/justfile index 259db8e115..fa74e2a730 100644 --- a/pkgs/id/justfile +++ b/pkgs/id/justfile @@ -242,6 +242,10 @@ crash-gate: # in parallel; together with the nightly full `crash-gate` they cover # every test crash-gate runs. write_corpus / write_corpus_identity stay # excluded everywhere (they rewrite the checked-in corpus files). +# The partition is guarded by .github/scripts/check-crash-gate-coverage.sh +# (#1635): a future #[ignore]d crash test matching none of the three split +# filters below fails the id PR guard job by name instead of silently +# losing all PR coverage. [group('test')] crash-gate-sampled: cargo test --release --features web --test crash -- --skip write_corpus