mirror of
https://github.com/block/buzz.git
synced 2026-11-04 00:12:02 +00:00
The 184 ignored Rust E2E tests in sprout-test-client were never run in CI — the relay only got exercised indirectly through Playwright. This adds a dedicated relay-e2e job and shared infra script so relay protocol correctness is tested directly. Changes: - scripts/start-relay-for-tests.sh: shared script that starts docker compose services, waits for health, applies schema, builds and starts the relay, and polls readiness. Used by both the new relay-e2e job and the refactored desktop-e2e-integration job. - .github/workflows/ci.yml: new relay-e2e job (triggers on crates/** changes, ~5 min) that runs all ignored E2E tests against the relay. desktop-e2e-integration refactored to use the shared script instead of inline infra setup. - crates/sprout-test-client/tests/e2e_persona.rs: 11 new E2E tests for kind:30175 persona events covering publish+query, NIP-33 replacement semantics, d-tag validation (empty, missing, too long, uppercase, special chars, underscore start), valid slug acceptance, and multiple personas per author. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
139 lines
5.1 KiB
Bash
Executable File
139 lines
5.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# =============================================================================
|
|
# start-relay-for-tests.sh — Start the Sprout relay and its backing services
|
|
# =============================================================================
|
|
# Shared script for CI jobs that need a running relay. Starts docker compose
|
|
# services, waits for health, applies the schema, builds the relay, starts it,
|
|
# and polls readiness.
|
|
#
|
|
# Usage:
|
|
# ./scripts/start-relay-for-tests.sh [--profile <cargo-profile>]
|
|
#
|
|
# Options:
|
|
# --profile <profile> Cargo build profile (default: ci)
|
|
#
|
|
# Exports:
|
|
# RELAY_URL=ws://localhost:3000
|
|
# =============================================================================
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
|
|
# ── Defaults ──────────────────────────────────────────────────────────────────
|
|
|
|
CARGO_PROFILE="${CARGO_PROFILE:-ci}"
|
|
|
|
# ── Parse args ────────────────────────────────────────────────────────────────
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--profile)
|
|
CARGO_PROFILE="$2"
|
|
shift 2
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# ── Colors ────────────────────────────────────────────────────────────────────
|
|
|
|
BLUE='\033[0;34m'
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
|
|
log() { echo -e "${BLUE}[relay-test]${NC} $*"; }
|
|
ok() { echo -e "${GREEN}[relay-test]${NC} $*"; }
|
|
err() { echo -e "${RED}[relay-test]${NC} $*" >&2; }
|
|
|
|
# ── Start docker compose services ────────────────────────────────────────────
|
|
|
|
cd "${REPO_ROOT}"
|
|
|
|
log "Starting docker compose services..."
|
|
docker compose up -d postgres redis typesense minio minio-init
|
|
|
|
# ── Wait for services to be healthy ──────────────────────────────────────────
|
|
|
|
wait_healthy() {
|
|
local service="$1"
|
|
local container="$2"
|
|
log "Waiting for ${service}..."
|
|
for attempt in $(seq 1 60); do
|
|
status=$(docker inspect --format='{{.State.Health.Status}}' "${container}" 2>/dev/null || echo "not_found")
|
|
if [ "${status}" = "healthy" ]; then
|
|
ok "${service} is healthy"
|
|
return 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
err "${service} did not become healthy within 120s"
|
|
docker logs "${container}" || true
|
|
return 1
|
|
}
|
|
|
|
wait_healthy "Postgres" "sprout-postgres"
|
|
wait_healthy "Redis" "sprout-redis"
|
|
wait_healthy "Typesense" "sprout-typesense"
|
|
wait_healthy "MinIO" "sprout-minio"
|
|
|
|
# ── Apply database schema ────────────────────────────────────────────────────
|
|
|
|
log "Applying database schema..."
|
|
export PGHOST=localhost
|
|
export PGPORT=5432
|
|
export PGUSER=sprout
|
|
export PGPASSWORD=sprout_dev
|
|
export PGDATABASE=sprout
|
|
|
|
./bin/pgschema apply --file schema/schema.sql --auto-approve
|
|
ok "Schema applied"
|
|
|
|
# ── Build relay ──────────────────────────────────────────────────────────────
|
|
|
|
log "Building relay (profile: ${CARGO_PROFILE})..."
|
|
cargo build --profile "${CARGO_PROFILE}" -p sprout-relay
|
|
ok "Relay built"
|
|
|
|
# ── Start relay ──────────────────────────────────────────────────────────────
|
|
|
|
log "Starting relay..."
|
|
nohup env \
|
|
DATABASE_URL=postgres://sprout:sprout_dev@localhost:5432/sprout \
|
|
REDIS_URL=redis://localhost:6379 \
|
|
TYPESENSE_URL=http://localhost:8108 \
|
|
TYPESENSE_API_KEY=sprout_dev_key \
|
|
RELAY_URL=ws://localhost:3000 \
|
|
SPROUT_BIND_ADDR=0.0.0.0:3000 \
|
|
SPROUT_REQUIRE_AUTH_TOKEN=false \
|
|
SPROUT_RECONCILE_CHANNELS=true \
|
|
SPROUT_GIT_PROBE_WRITERS=8 \
|
|
"./target/${CARGO_PROFILE}/sprout-relay" > /tmp/sprout-relay.log 2>&1 &
|
|
echo $! > /tmp/sprout-relay.pid
|
|
|
|
# ── Poll readiness ───────────────────────────────────────────────────────────
|
|
|
|
log "Waiting for relay readiness..."
|
|
for attempt in $(seq 1 60); do
|
|
if ! kill -0 "$(cat /tmp/sprout-relay.pid)" 2>/dev/null; then
|
|
err "Relay process died"
|
|
cat /tmp/sprout-relay.log
|
|
exit 1
|
|
fi
|
|
status_code=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3000/_readiness || true)
|
|
if [ "${status_code}" = "200" ]; then
|
|
ok "Relay is ready at ws://localhost:3000"
|
|
export RELAY_URL=ws://localhost:3000
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
err "Relay did not become ready within 60s"
|
|
cat /tmp/sprout-relay.log
|
|
exit 1
|