|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# verify.sh -- single advisory pre-PR umbrella for t27. |
| 4 | +# |
| 5 | +# The repo has accumulated several small, read-only developer checks, each with |
| 6 | +# its own entry point: the NMSE seal-freshness reporter (scripts/reseal-check.sh |
| 7 | +# / `make seal-check`, #1106), the #969 dead-code warning meter |
| 8 | +# (scripts/warnings-baseline.sh / `make warnings-baseline`, #1119), and the test |
| 9 | +# suite. Before opening a PR a contributor wants to glance at all of them at |
| 10 | +# once. This script runs them back-to-back and prints a single compact summary. |
| 11 | +# |
| 12 | +# It is ADVISORY ONLY. It never edits code, never reseals, never blocks: every |
| 13 | +# sub-check's outcome is reported and the umbrella ALWAYS exits 0 so it can be |
| 14 | +# dropped into a pre-push habit without ever failing a push. The actual gate |
| 15 | +# remains the four required CI checks (check-now-freshness / validate / check / |
| 16 | +# check-linked-issue); this is a local convenience, not a substitute. |
| 17 | +# |
| 18 | +# Sub-checks (each best-effort; a missing script is reported as SKIP): |
| 19 | +# 1. seal -- scripts/reseal-check.sh --quiet (NMSE seal freshness) |
| 20 | +# 2. warnings -- scripts/warnings-baseline.sh --quiet (#969 meter) |
| 21 | +# 3. test -- a quick cargo test of the compiler reject/accept suite |
| 22 | +# (the negative-test gate from variants K/M/Q), unless |
| 23 | +# VERIFY_FULL_TEST=1 asks for the whole binary test run. |
| 24 | +# |
| 25 | +# Usage: |
| 26 | +# scripts/verify.sh # run all sub-checks, print summary, exit 0 |
| 27 | +# scripts/verify.sh --quiet # print only the final one-line summary |
| 28 | +# VERIFY_SKIP_TEST=1 scripts/verify.sh # skip the (slow) test sub-check |
| 29 | +# VERIFY_FULL_TEST=1 scripts/verify.sh # run the full binary test suite |
| 30 | +# |
| 31 | +# Anchor: phi^2 + phi^-2 = 3 |
| 32 | + |
| 33 | +set -uo pipefail |
| 34 | + |
| 35 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 36 | +REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 37 | +cd "$REPO_ROOT" |
| 38 | + |
| 39 | +QUIET=0 |
| 40 | +if [ "${1:-}" = "--quiet" ]; then QUIET=1; fi |
| 41 | +log() { if [ "$QUIET" -eq 0 ]; then echo "$@"; fi; } |
| 42 | + |
| 43 | +# Prefer an explicit cargo if present; fall back to PATH. |
| 44 | +CARGO_BIN="cargo" |
| 45 | +if [ -x "$HOME/.cargo/bin/cargo" ]; then CARGO_BIN="$HOME/.cargo/bin/cargo"; fi |
| 46 | + |
| 47 | +# Collected one-line verdicts for the final summary. |
| 48 | +SUMMARY="" |
| 49 | +add_summary() { SUMMARY="${SUMMARY}${SUMMARY:+ | }$1"; } |
| 50 | + |
| 51 | +log "================================================================" |
| 52 | +log " t27 pre-PR verify (advisory umbrella; never blocks)" |
| 53 | +log "================================================================" |
| 54 | + |
| 55 | +# ---------------------------------------------------------------------------- |
| 56 | +# 1. NMSE seal freshness (read-only; reseal stays an explicit reviewed step). |
| 57 | +# ---------------------------------------------------------------------------- |
| 58 | +if [ -x scripts/reseal-check.sh ]; then |
| 59 | + SEAL_OUT="$(scripts/reseal-check.sh --quiet 2>/dev/null)" |
| 60 | + SEAL_CODE=$? |
| 61 | + case "$SEAL_CODE" in |
| 62 | + 0) SEAL_VERDICT="seal:FRESH" ;; |
| 63 | + 2) SEAL_VERDICT="seal:STALE (advisory; run 'make seal' if intended)" ;; |
| 64 | + 3) SEAL_VERDICT="seal:UNSEALED (advisory)" ;; |
| 65 | + *) SEAL_VERDICT="seal:UNKNOWN (exit $SEAL_CODE)" ;; |
| 66 | + esac |
| 67 | + log " [1/3] seal-check -> ${SEAL_OUT:-$SEAL_VERDICT}" |
| 68 | +else |
| 69 | + SEAL_VERDICT="seal:SKIP (script missing)" |
| 70 | + log " [1/3] seal-check -> SKIP (scripts/reseal-check.sh not found)" |
| 71 | +fi |
| 72 | +add_summary "$SEAL_VERDICT" |
| 73 | + |
| 74 | +# ---------------------------------------------------------------------------- |
| 75 | +# 2. #969 dead-code warning meter (read-only; builds with JSON diagnostics). |
| 76 | +# ---------------------------------------------------------------------------- |
| 77 | +if [ -x scripts/warnings-baseline.sh ]; then |
| 78 | + WARN_OUT="$(scripts/warnings-baseline.sh --quiet 2>/dev/null)" |
| 79 | + WARN_CODE=$? |
| 80 | + case "$WARN_CODE" in |
| 81 | + 0) WARN_VERDICT="warnings:OK" ;; |
| 82 | + 1) WARN_VERDICT="warnings:REGRESSED (advisory; above baseline)" ;; |
| 83 | + 2) WARN_VERDICT="warnings:BUILD-FAILED" ;; |
| 84 | + *) WARN_VERDICT="warnings:UNKNOWN (exit $WARN_CODE)" ;; |
| 85 | + esac |
| 86 | + log " [2/3] warnings -> ${WARN_OUT:-$WARN_VERDICT}" |
| 87 | +else |
| 88 | + WARN_VERDICT="warnings:SKIP (script missing)" |
| 89 | + log " [2/3] warnings -> SKIP (scripts/warnings-baseline.sh not found)" |
| 90 | +fi |
| 91 | +add_summary "$WARN_VERDICT" |
| 92 | + |
| 93 | +# ---------------------------------------------------------------------------- |
| 94 | +# 3. Quick test of the negative-test gate (variants K/M/Q) -- the fastest |
| 95 | +# high-signal correctness check. Opt into the full suite with |
| 96 | +# VERIFY_FULL_TEST=1, or skip tests entirely with VERIFY_SKIP_TEST=1. |
| 97 | +# ---------------------------------------------------------------------------- |
| 98 | +if [ "${VERIFY_SKIP_TEST:-0}" = "1" ]; then |
| 99 | + TEST_VERDICT="test:SKIP (VERIFY_SKIP_TEST=1)" |
| 100 | + log " [3/3] test -> SKIP (VERIFY_SKIP_TEST=1)" |
| 101 | +else |
| 102 | + if [ "${VERIFY_FULL_TEST:-0}" = "1" ]; then |
| 103 | + TEST_DESC="full binary test suite" |
| 104 | + TEST_FILTER="" |
| 105 | + else |
| 106 | + TEST_DESC="compiler reject/accept gate" |
| 107 | + TEST_FILTER="tests_compiler_rejects" |
| 108 | + fi |
| 109 | + if "$CARGO_BIN" test --bin t27c $TEST_FILTER >/dev/null 2>&1; then |
| 110 | + TEST_VERDICT="test:PASS ($TEST_DESC)" |
| 111 | + log " [3/3] test -> PASS ($TEST_DESC)" |
| 112 | + else |
| 113 | + TEST_VERDICT="test:FAIL ($TEST_DESC) -- advisory, inspect with 'cargo test'" |
| 114 | + log " [3/3] test -> FAIL ($TEST_DESC) (advisory; re-run 'cargo test --bin t27c' for detail)" |
| 115 | + fi |
| 116 | +fi |
| 117 | +add_summary "$TEST_VERDICT" |
| 118 | + |
| 119 | +log "----------------------------------------------------------------" |
| 120 | +log " advisory only: never edits code, never reseals, never gates CI." |
| 121 | +log " required CI checks remain: check-now-freshness / validate /" |
| 122 | +log " check / check-linked-issue." |
| 123 | +log "----------------------------------------------------------------" |
| 124 | + |
| 125 | +# Final compact summary. Always printed (even with --quiet) and we ALWAYS exit 0 |
| 126 | +# so the umbrella is safe to wire into a pre-push habit without ever blocking. |
| 127 | +echo "verify: $SUMMARY" |
| 128 | +exit 0 |
0 commit comments