diff --git a/scripts/verify_phase01.sh b/scripts/verify_phase01.sh new file mode 100755 index 0000000..ef66ba5 --- /dev/null +++ b/scripts/verify_phase01.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash +# Phase 01 verification script. +# Confirms the three-repo scaffold exists under the continuous-intelligence +# Gitea org and that the Phase 01 visible artifacts (placeholder index.html on +# acdl-evidence; qa + prod branches on acdl-contracts) are present. +# +# Usage: ACDL_GITEA_TOKEN= scripts/verify_phase01.sh +# Exit codes: 0 = all checks passed; 1 = one or more checks failed. + +set -euo pipefail + +GITEA_HOST="${GITEA_HOST:-https://git.cloudinit.dev}" +ORG="continuous-intelligence" +TOKEN="${ACDL_GITEA_TOKEN:-}" +AUTH_HEADER="" +if [ -n "$TOKEN" ]; then + AUTH_HEADER="-H \"Authorization: token ${TOKEN}\"" +fi + +fail_count=0 +note() { printf ' [%s] %s\n' "$1" "$2"; } +pass() { note "PASS" "$1"; } +fail() { note "FAIL" "$1"; fail_count=$((fail_count + 1)); } + +echo "== Phase 01 verification ==" +echo "Host: $GITEA_HOST" +echo "Org: $ORG" +echo "Token: ${TOKEN:+}${TOKEN:-}" +echo + +# --- Check 1: acdl-contracts repo exists --- +echo "-- Check 1: acdl-contracts repo exists --" +status=$(curl -sS -o /tmp/p01_contracts.json -w "%{http_code}" \ + -H "Authorization: token ${TOKEN}" \ + "${GITEA_HOST}/api/v1/repos/${ORG}/acdl-contracts") +if [ "$status" = "200" ]; then + default_branch=$(python3 -c "import json; print(json.load(open('/tmp/p01_contracts.json')).get('default_branch','?'))") + pass "acdl-contracts exists (default_branch=${default_branch})" +else + fail "acdl-contracts GET returned HTTP ${status}" +fi + +# --- Check 2: acdl-evidence repo exists --- +echo "-- Check 2: acdl-evidence repo exists --" +status=$(curl -sS -o /tmp/p01_evidence.json -w "%{http_code}" \ + -H "Authorization: token ${TOKEN}" \ + "${GITEA_HOST}/api/v1/repos/${ORG}/acdl-evidence") +if [ "$status" = "200" ]; then + default_branch=$(python3 -c "import json; print(json.load(open('/tmp/p01_evidence.json')).get('default_branch','?'))") + pass "acdl-evidence exists (default_branch=${default_branch})" +else + fail "acdl-evidence GET returned HTTP ${status}" +fi + +# --- Check 3: acdl-evidence raw index.html returns 200 (Pages substitute per D-012/D-016) --- +echo "-- Check 3: acdl-evidence raw index.html returns 200 --" +index_url="${GITEA_HOST}/${ORG}/acdl-evidence/raw/branch/main/index.html" +status=$(curl -sS -o /tmp/p01_index.html -w "%{http_code}" \ + "${index_url}") +if [ "$status" = "200" ]; then + body_size=$(wc -c < /tmp/p01_index.html) + if grep -q "ACDL Evidence" /tmp/p01_index.html; then + pass "raw index.html returns 200 with placeholder body (${body_size} bytes)" + else + fail "raw index.html returns 200 but body does not contain 'ACDL Evidence' marker" + fi +else + fail "GET ${index_url} returned HTTP ${status}" +fi + +# --- Check 4: qa + prod branches exist on acdl-contracts --- +echo "-- Check 4: qa + prod branches exist on acdl-contracts --" +status=$(curl -sS -o /tmp/p01_branches.json -w "%{http_code}" \ + -H "Authorization: token ${TOKEN}" \ + "${GITEA_HOST}/api/v1/repos/${ORG}/acdl-contracts/branches?limit=50") +if [ "$status" != "200" ]; then + fail "list branches on acdl-contracts returned HTTP ${status}" +else + for want in qa prod; do + if python3 -c " +import json, sys +branches = json.load(open('/tmp/p01_branches.json')) +names = [b.get('name', '') for b in branches] +sys.exit(0 if '${want}' in names else 1) +"; then + pass "branch '${want}' exists on acdl-contracts" + else + fail "branch '${want}' missing on acdl-contracts" + fi + done +fi + +echo +echo "== Summary ==" +if [ "$fail_count" -eq 0 ]; then + echo "Phase 01 verification PASSED (all checks ok)" + exit 0 +else + echo "Phase 01 verification FAILED (${fail_count} check(s) failed)" + exit 1 +fi \ No newline at end of file