thermograph/backend/scripts/smoke.sh
Emi Griffith df409f88b3
All checks were successful
PR build (required check) / changes (pull_request) Successful in 6s
secrets-guard / encrypted (pull_request) Successful in 4s
shell-lint / shellcheck (pull_request) Successful in 6s
PR build (required check) / validate-observability (pull_request) Successful in 20s
PR build (required check) / build-frontend (pull_request) Successful in 37s
PR build (required check) / build-backend (pull_request) Successful in 51s
PR build (required check) / gate (pull_request) Successful in 1s
registry: move image and repo references to the Jinemi namespace
Repos moved to the Jinemi org; the container packages did not follow, since
Forgejo does not transfer packages with a repo. The deploy path still resolved
`emi/thermograph/*` — a user_redirect to admin_emi — while build-push.yml
derives its push path from ${github.repository}, now jinemi/thermograph. The
next backend or frontend build would have published somewhere no deploy looks.

Point the image paths at jinemi/thermograph/* (lowercase: OCI references admit
no uppercase, which is why build-push.yml already pipes through tr), the clone
URLs at Jinemi/thermograph, and the registry logins at admin_emi — the account
that actually owns the tokens, rather than the redirect.

The live tags and both ci-runner tags were copied into the Jinemi namespace
first, so the switch has something to pull. thermograph-infra,
thermograph-observability and the retired */app packages stay under admin_emi;
they did not move.
2026-08-01 09:25:02 -07:00

45 lines
2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Image boot-smoke: prove the backend IMAGE actually boots and serves its contract
# (a `docker build` succeeding does not prove the container starts). Builds the image
# locally (or uses a provided BACKEND_IMAGE_TAG), runs it + a throwaway TimescaleDB via
# docker-compose.test.yml, waits for /healthz, then asserts /healthz and the version
# endpoint. Always tears the stack down.
#
# ./scripts/smoke.sh # build :local and smoke it
# BACKEND_IMAGE_TAG=sha-abc123 ./scripts/smoke.sh # smoke a published image (CI)
set -euo pipefail
cd "$(dirname "$0")/.."
export POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-smoke}"
# The image to smoke, pulled from the registry (no local build). CI passes the just-
# pushed sha (BACKEND_IMAGE_TAG=sha-<12hex>); locally it defaults to a published tag.
export BACKEND_IMAGE_TAG="${BACKEND_IMAGE_TAG:-v0.0.2-split-ci}"
IMG="${REGISTRY_HOST:-git.thermograph.org}/${BACKEND_IMAGE_PATH:-admin_emi/thermograph-backend/app}:${BACKEND_IMAGE_TAG}"
export SMOKE_HOST_PORT="${SMOKE_HOST_PORT:-18137}"
COMPOSE=(docker compose -f docker-compose.test.yml)
PORT_URL="http://127.0.0.1:${SMOKE_HOST_PORT}"
cleanup() { echo "==> tearing down"; "${COMPOSE[@]}" down -v --remove-orphans >/dev/null 2>&1 || true; }
trap cleanup EXIT
echo "==> pulling $IMG"
"${COMPOSE[@]}" pull backend
echo "==> starting backend + db ($IMG)"
"${COMPOSE[@]}" up -d
echo "==> waiting for /healthz (up to 90s)"
for _ in $(seq 1 45); do
if curl -fsS -o /dev/null "$PORT_URL/healthz"; then ok=1; break; fi
sleep 2
done
[ "${ok:-}" = 1 ] || { echo "!! backend never became healthy"; "${COMPOSE[@]}" logs --tail=40 backend; exit 1; }
echo "==> asserting contract"
curl -fsS "$PORT_URL/healthz" >/dev/null && echo " /healthz 200 ok"
ver=$(curl -fsS "$PORT_URL/api/version")
echo " /api/version -> $ver"
echo "$ver" | grep -q '"backend_version"[[:space:]]*:[[:space:]]*"2"' \
|| { echo "!! /api/version did not report backend_version=2"; exit 1; }
echo "==> SMOKE PASSED"