From b9e5e818a904ac5058155caef5315aeb1d1a921a Mon Sep 17 00:00:00 2001 From: Zhengchao An Date: Fri, 10 Jul 2026 22:19:17 +0800 Subject: [PATCH] ci: fix migration-gate count guard failing on every PR (nextest JSON counting) (#4686) ci: count migration-gate tests via nextest JSON, not human-format indentation The count-floor guard (#4673) parsed nextest's human list format with grep -c '^ '. CI's newer nextest emits a different indentation, so the count collapsed to 0 and the gate failed on every PR based on current main (first observed on #4683, then #4674/#4677/#4680). Count via --message-format json + jq instead, which is stable across versions, and fail loudly if the JSON shape ever changes. --- scripts/check_migration_gate_count.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/check_migration_gate_count.sh b/scripts/check_migration_gate_count.sh index 22c853e71..0e3bf0a6c 100755 --- a/scripts/check_migration_gate_count.sh +++ b/scripts/check_migration_gate_count.sh @@ -54,12 +54,18 @@ if [[ "$mode" == "all" || "$mode" == "check" ]]; then exit 1 fi - # Human-format list: binary headers start at column 0, one test per - # 4-space-indented line. A nextest failure aborts via set -e with its - # stderr visible; an output-format change collapses the count to 0 and - # fails loudly rather than silently passing. - list_output="$(cargo nextest list -p rustfs-ecstore --lib -E "$MIGRATION_GATE_FILTER")" - count="$(printf '%s\n' "$list_output" | grep -c '^ ' || true)" + # Count via the structured JSON listing, not the human format: the + # human format's indentation varies across nextest versions (CI's newer + # nextest emitted a layout where no line matched '^ ', collapsing the + # count to 0 and failing every PR). A nextest failure aborts via set -e + # with its stderr visible; a JSON schema change makes jq fail loudly + # rather than silently passing. + count="$(cargo nextest list -p rustfs-ecstore --lib -E "$MIGRATION_GATE_FILTER" --message-format json \ + | jq '[."rust-suites"[].testcases[] | select(."filter-match".status == "matches")] | length')" + if ! [[ "$count" =~ ^[0-9]+$ ]]; then + echo "error: could not parse nextest JSON listing (got count: '$count')" >&2 + exit 1 + fi if ((count < floor)); then echo "error: migration gate selects $count tests, below the committed floor of $floor." >&2