diff --git a/scripts/check-pr-sg0-net-shrink-discipline.sh b/scripts/check-pr-sg0-net-shrink-discipline.sh index 60e5cb21b34..a791bb9c2a2 100755 --- a/scripts/check-pr-sg0-net-shrink-discipline.sh +++ b/scripts/check-pr-sg0-net-shrink-discipline.sh @@ -270,6 +270,37 @@ sg0_net_path_delta_from_git_diff() { echo $((head - base)) } +sg0_assert_ci_wiring() { + local workflow=".github/workflows/ci.yml" + local self_test_line body_check_line bootstrap_verify_line + + if [ ! -f "$workflow" ]; then + echo "::error::missing $workflow; gate #75 requires CI wiring for SG-0 PR-body discipline" + return 1 + fi + + self_test_line=$(grep -nE 'bash[[:space:]]+scripts/check-pr-sg0-net-shrink-discipline\.sh[[:space:]]+--self-test([[:space:]]|$)' "$workflow" | head -1 | cut -d: -f1 || true) + body_check_line=$(grep -nE 'bash[[:space:]]+scripts/check-pr-sg0-net-shrink-discipline\.sh([[:space:]]|$)' "$workflow" | grep -v -- '--self-test' | head -1 | cut -d: -f1 || true) + bootstrap_verify_line=$(grep -nE '^[[:space:]]*run:[[:space:]]+.*regen_bootstrap[[:space:]].*--verify' "$workflow" | head -1 | cut -d: -f1 || true) + + if [ -z "$self_test_line" ]; then + echo "::error::$workflow no longer runs check-pr-sg0-net-shrink-discipline.sh --self-test" + return 1 + fi + if [ -z "$body_check_line" ]; then + echo "::error::$workflow no longer runs check-pr-sg0-net-shrink-discipline.sh for pull_request PR-body enforcement" + return 1 + fi + if [ -z "$bootstrap_verify_line" ]; then + echo "::error::$workflow no longer has the bootstrap verify step used as the gate-order anchor" + return 1 + fi + if [ "$self_test_line" -ge "$body_check_line" ] || [ "$body_check_line" -ge "$bootstrap_verify_line" ]; then + echo "::error::$workflow must run SG-0 discipline self-test, then PR-body enforcement, before bootstrap verify (gate #75 CI-active receipt)" + return 1 + fi +} + self_test() { local failed=0 run_case() { @@ -407,6 +438,10 @@ self_test() { -3 \ pass + if ! sg0_assert_ci_wiring; then + failed=1 + fi + if [ "$failed" -ne 0 ]; then exit 1 fi