Files
faunosteo/scripts/avatar-e2e.sh
T
bchanot dd4c35c061 chore(workspace): DEV origin on the private network — scripts/dev-env.sh (FAUNOSTEO_DEV_HOST detected or set), Supabase CLI wrapper, pnpm dev on the LAN address, config.toml URLs via env(); ENVIRONMENTS.md (identity Faunosteo / faunosteo.com, DEV / STAGING / PROD, exposure table, owner procedure)
The owner tests from other devices of the private network: every test
surface is addressed by the machine's LAN address, never 127.0.0.1 or
localhost, never hard-coded. scripts/dev-env.sh decides the host once
(hostname -I, FAUNOSTEO_DEV_HOST override, production hosts refused);
scripts/supabase.sh exports it for every CLI call (pnpm db:*, pnpm supabase)
because config.toml now reads api.external_url (mail links), auth.site_url
and studio.api_url with env(); scripts/dev.sh = pnpm dev on that origin,
pnpm dev:offline keeps the local tool alone; dev-lan.sh removed.
Verified: GoTrue API_EXTERNAL_URL and Studio SUPABASE_PUBLIC_URL on the LAN
address, a signup mail linking to http://<lan>:54321/auth/v1/verify, the
four published ports answering from a separate Docker network, and the
10-step procedure in headless Chromium at the LAN origin with every request
URL audited (no 127.0.0.1 / localhost).
2026-10-13 22:06:25 +02:00

59 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Real-stack end-to-end run of the avatar flow (docs/development/STORAGE.md §6):
# starts the worker container against the local Supabase stack with a fast sweep
# and no quarantine grace, runs packages/supabase/tests/e2e, stops the container.
# Needs: `pnpm db:start` done, Docker, the worker image (`pnpm worker:image`,
# built here when absent). The keys come from `supabase status`; the service key
# reaches the container through a 600-mode temporary env file, never the command line.
set -euo pipefail
cd "$(dirname "$0")/.."
network="${SUPABASE_NETWORK:-supabase_network_faunosteo}"
kong="${SUPABASE_INTERNAL_URL:-http://supabase_kong_faunosteo:8000}"
image="${WORKER_IMAGE:-faunosteo_worker:dev}"
name="faunosteo_worker_e2e"
. scripts/dev-env.sh
status="$(node_modules/.bin/supabase status -o env 2>/dev/null)" \
|| { echo "avatar-e2e: the local stack is not running (pnpm db:start)" >&2; exit 1; }
value() { printf '%s\n' "$status" | sed -n "s/^$1=\"\(.*\)\"$/\1/p"; }
api_url="$(value API_URL)"
anon_key="$(value ANON_KEY)"
service_key="$(value SERVICE_ROLE_KEY)"
[ -n "$api_url" ] && [ -n "$anon_key" ] && [ -n "$service_key" ] \
|| { echo "avatar-e2e: could not read the keys from supabase status" >&2; exit 1; }
if ! docker image inspect "$image" >/dev/null 2>&1; then
echo "== building $image"
docker build -f crates/worker/Dockerfile -t "$image" .
fi
env_file="$(mktemp)"
chmod 600 "$env_file"
cleanup() {
echo "== worker log (last lines)"
docker logs --tail 40 "$name" 2>/dev/null || true
docker rm -f "$name" >/dev/null 2>&1 || true
rm -f "$env_file"
}
trap cleanup EXIT
{
echo "SUPABASE_URL=$kong"
echo "SUPABASE_SERVICE_ROLE_KEY=$service_key"
echo "WORKER_ID=e2e"
echo "WORKER_POLL_SECONDS=1"
echo "WORKER_SWEEP_SECONDS=5"
echo "WORKER_QUARANTINE_GRACE_SECONDS=0"
} > "$env_file"
docker rm -f "$name" >/dev/null 2>&1 || true
echo "== starting $name on $network"
docker run -d --name "$name" --read-only --cap-drop ALL \
--security-opt no-new-privileges:true --memory 512m --cpus 1 --pids-limit 64 \
--network "$network" --env-file "$env_file" "$image" run >/dev/null
echo "== e2e suite"
SUPABASE_URL="$api_url" SUPABASE_ANON_KEY="$anon_key" SUPABASE_SERVICE_ROLE_KEY="$service_key" \
pnpm --filter @faunosteo/supabase test:e2e