Files
clawmates/scripts/e2e-backend.sh
T
Omar Sobh 298eb8e20e
ci / gates (push) Successful in 6s
ci / frontend (push) Successful in 23s
ci / rust (push) Successful in 3m43s
ci / e2e (push) Failing after 14s
ci / publish (push) Successful in 36s
e2e: move backend/dex/frontend from 8080 to 18080 so runners don't collide
Two of the fleet's Gitea Actions runners (morpheus, architect) already
had 8080 permanently bound by unrelated services (nginx on morpheus,
envio-hasura on architect) — every e2e run scheduled there died at
playwright's webServer preflight with "http://127.0.0.1:8080/healthz is
already used". 18080 is unused across morpheus/tank/architect.

Swap 8080 → 18080 in the eight e2e-scoped sites: clawmates.e2e.toml
(listen_addr + slack base_url + oauth redirect_base), dex.yaml (client
redirect URIs must match backend), playwright.config.ts + tests
(p4-slack, p6-oauth), the http.ts dev-fallback origin, and the two
shell scripts (e2e-backend safety check, rehearse-install healthz probe).

Prod compose (/opt/clawmates/docker-compose.yml on gw-04) is untouched;
prod continues to expose the server on 8080 internally on the compose
network (that's per-network, not host-shared).
2026-07-05 20:25:27 -07:00

55 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Boots the real backend for Playwright: a fresh Postgres container plus
# clawmates-server in e2e mode (deterministic seed). Playwright's webServer
# waits on the /healthz port.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
docker rm -f clawmates-e2e-pg >/dev/null 2>&1 || true
docker run -d --name clawmates-e2e-pg \
-e POSTGRES_PASSWORD=e2e \
-e POSTGRES_DB=clawmates_e2e \
-p 54330:5432 \
postgres:16-alpine >/dev/null
until docker exec clawmates-e2e-pg pg_isready -U postgres -q >/dev/null 2>&1; do
sleep 0.5
done
# Real OIDC IdP for the OAuth browser-flow journey.
docker rm -f clawmates-e2e-dex >/dev/null 2>&1 || true
docker run -d --name clawmates-e2e-dex \
-p 54556:5556 \
-v "$ROOT/deploy/e2e/dex.yaml:/etc/dex/config.yaml:ro" \
dexidp/dex:v2.41.1 dex serve /etc/dex/config.yaml >/dev/null
until curl -fsS http://127.0.0.1:54556/dex/.well-known/openid-configuration >/dev/null 2>&1; do
sleep 0.5
done
# Refuse to run against someone else's 8080 (e.g. the compose stack):
# reuseExistingServer would silently point every journey at the wrong
# backend with the wrong seed.
if curl -fsS -o /dev/null --max-time 2 http://127.0.0.1:18080/healthz 2>/dev/null; then
echo "e2e-backend: port 8080 is already serving — stop the other stack first" >&2
echo " (docker compose -f deploy/compose/docker-compose.yml down)" >&2
exit 1
fi
cd "$ROOT"
export CLAWMATES_MODE=e2e
export CLAWMATES_CONFIG="$ROOT/deploy/e2e/clawmates.e2e.toml"
export SQLX_OFFLINE=true
# The secret broker daemon (own process, like production).
export CLAWMATES_DATABASE__URL="postgres://postgres:[email protected]:54330/clawmates_e2e"
export CLAWMATES_BROKER_SOCKET="/tmp/clawmates-e2e-broker.sock"
export CLAWMATES_BROKER_KEY_FILE="/tmp/clawmates-e2e-broker.key"
rm -f "$CLAWMATES_BROKER_SOCKET" "$CLAWMATES_BROKER_KEY_FILE"
cargo build -p clawmates-server -p clawmates-broker
cargo run -p clawmates-broker &
BROKER_PID=$!
trap 'kill $BROKER_PID 2>/dev/null' EXIT
exec cargo run -p clawmates-server