Site deploy checks: no-cache headers on every read and a 150 s window (22:27 BST: the litepaper served the previous deployment for over 90 s after /api/live had moved, a false DEPLOY RED)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
igneum-labs 2026-10-07 21:31:09 +00:00
parent 476af738b8
commit 408ffa9dec

View file

@ -21,13 +21,14 @@ MINERS_MIN_ROWS="${MINERS_MIN_ROWS:-30}"
SITE="${SITE_URL:-https://igneum.network}"
post_checks() { # one pass: prints the first mismatch as "field: detail" and returns 1, or returns 0 silently
local j n idx m rows
j=$(curl -fsS --max-time 20 "$SITE/api/live?x=$RANDOM" 2>/dev/null) || { echo "api/live: not reachable"; return 1; }
local nc=(-H 'Cache-Control: no-cache' -H 'Pragma: no-cache')
j=$(curl -fsS "${nc[@]}" --max-time 20 "$SITE/api/live?x=$RANDOM" 2>/dev/null) || { echo "api/live: not reachable"; return 1; }
n=$(printf '%s' "$j" | python3 -c 'import sys,json; print(json.load(sys.stdin)["state"]["network"])' 2>/dev/null || echo "?")
[ "$n" = "$LIVE_NETWORK" ] || { echo "api/live network: $n (want $LIVE_NETWORK)"; return 1; }
idx=$(curl -fsS --max-time 20 "$SITE/?x=$RANDOM" 2>/dev/null) || { echo "index: not reachable"; return 1; }
idx=$(curl -fsS "${nc[@]}" --max-time 20 "$SITE/?x=$RANDOM" 2>/dev/null) || { echo "index: not reachable"; return 1; }
for m in "${INDEX_STRINGS[@]}"; do printf '%s' "$idx" | /usr/bin/grep -qF -- "$m" || { echo "index string missing: \"$m\""; return 1; }; done
curl -fsS --max-time 20 "$SITE$LEGAL_PAGE?x=$RANDOM" 2>/dev/null | /usr/bin/grep -qiF -- "$LEGAL_STRING" || { echo "legal string missing on $LEGAL_PAGE: \"$LEGAL_STRING\""; return 1; }
rows=$(curl -fsS --max-time 20 "$SITE/miners?x=$RANDOM" 2>/dev/null | /usr/bin/grep -c '<tr class="row"' || true)
curl -fsS "${nc[@]}" --max-time 20 "$SITE$LEGAL_PAGE?x=$RANDOM" 2>/dev/null | /usr/bin/grep -qiF -- "$LEGAL_STRING" || { echo "legal string missing on $LEGAL_PAGE: \"$LEGAL_STRING\""; return 1; }
rows=$(curl -fsS "${nc[@]}" --max-time 20 "$SITE/miners?x=$RANDOM" 2>/dev/null | /usr/bin/grep -c '<tr class="row"' || true)
[ "${rows:-0}" -ge "$MINERS_MIN_ROWS" ] || { echo "miners rows: ${rows:-0} (want at least $MINERS_MIN_ROWS)"; return 1; }
echo "ok: api/live $n, ${#INDEX_STRINGS[@]} index strings, the legal line on $LEGAL_PAGE, $rows miners rows"
}
@ -61,7 +62,7 @@ echo "deploying $(TZ=UTC date +%H:%M:%SZ)"
OUT=$( cd "$W" && npx --yes vercel@latest --global-config "$HOME/.config/igneum/vercel" --scope igneum deploy --prod --yes 2>&1 ) || { echo "$OUT" | tail -5 >&2; exit 1; }
URL=$(echo "$OUT" | grep -oE 'https://[a-z0-9.-]*vercel\.app' | tail -1)
# the post-deploy checks, retried while the edge still serves the previous deployment (up to 90 s)
verdict=""; for i in $(seq 1 18); do verdict=$(post_checks 2>&1) && break; sleep 5; done
verdict=""; for i in $(seq 1 30); do verdict=$(post_checks 2>&1) && break; sleep 5; done # up to 150 s: the edge serves the previous deployment per path for a while (22:27 BST: the litepaper lagged the API by over 90 s)
case "$verdict" in ok:*) echo "post-deploy checks $verdict" ;; *) echo "DEPLOY RED $verdict (commit $SHORT at the edge $URL, $(TZ=Europe/London date +%H:%M) BST)" >&2; exit 1 ;; esac
echo "SITE DEPLOYED commit $SHORT at $(TZ=UTC date +%H:%M:%SZ) UTC ($(TZ=Europe/London date +%H:%M) BST): $URL -> https://igneum.network"
echo "$OUT" | grep -iE "Production:|Aliased|error" | head -3