#!/usr/bin/env bash # Staging acceptance test (Phase 4 §23/§18) — the four things a human needs before promoting a # build: app deploys, migrations ran clean, the Gateway/Platform API/Provisioner are reachable, # and (if OWNER_EMAIL/OWNER_PASSWORD are provided) a real assessment can be started end to end. # Reuses platform/test/e2e-phase3b.js against the staging Gateway URL rather than re-inventing # a parallel smoke-test harness — that suite already IS the full acceptance chain. set -euo pipefail STAGING_URL="${STAGING_GATEWAY_URL:?set STAGING_GATEWAY_URL, e.g. https://staging.academy.example.com}" echo "==> Health checks" # Phase 4.1 §23: this was `curl ... && echo ...` as one statement — under `set -e`, a failing # command that ISN'T the last one in an && list does not trigger the shell to exit (a # well-known bash gotcha), so a genuinely unreachable staging Gateway used to fall through # silently instead of failing this script. Split into two statements so curl's own exit status # is what `set -e` actually sees. Found by infra/scripts/drills/test-ci-fails-closed.sh. curl -sf "$STAGING_URL/healthz" > /dev/null echo "OK: Gateway /healthz" if [ -n "${OWNER_EMAIL:-}" ] && [ -n "${OWNER_PASSWORD:-}" ]; then echo "==> Full acceptance run (platform/test/e2e-phase3b.js against staging)" cd "$(dirname "$0")/../../platform" GATEWAY_URL="$STAGING_URL" OWNER_EMAIL="$OWNER_EMAIL" OWNER_PASSWORD="$OWNER_PASSWORD" \ SKIP_RESTART_TEST=1 node test/e2e-phase3b.js else echo "==> Skipping full e2e run — set OWNER_EMAIL/OWNER_PASSWORD for a real classroom-workflow" echo " smoke test (bootstrap one first against staging: platform/api/bootstrap-owner.js)." fi echo "OK: staging smoke test passed"