#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) ROOT=$(cd "$SCRIPT_DIR/../.." && pwd) COMPOSE_FILE="$ROOT/devops/compose/docker-compose.stella-ops.yml" PROJECT_NAME=${PROJECT_NAME:-symbolsci} ARTIFACT_DIR=${ARTIFACT_DIR:-"$ROOT/out/symbols-ci"} STAMP=$(date -u +"%Y%m%dT%H%M%SZ") RUN_DIR="$ARTIFACT_DIR/$STAMP" mkdir -p "$RUN_DIR" log() { printf '[%s] %s\n' "$(date -u +%H:%M:%S)" "$*"; } cleanup() { local code=$? log "Collecting compose logs" docker compose -f "$COMPOSE_FILE" -p "$PROJECT_NAME" logs >"$RUN_DIR/compose.log" 2>&1 || true log "Tearing down stack" docker compose -f "$COMPOSE_FILE" -p "$PROJECT_NAME" down -v >/dev/null 2>&1 || true log "Artifacts in $RUN_DIR" exit $code } trap cleanup EXIT log "Pulling images" docker compose -f "$COMPOSE_FILE" -p "$PROJECT_NAME" pull --ignore-pull-failures >/dev/null 2>&1 || true log "Starting services" docker compose -f "$COMPOSE_FILE" -p "$PROJECT_NAME" up -d stellaops-rustfs stellaops-postgres --remove-orphans wait_http() { local url=$1; local name=$2; local tries=${3:-30} for i in $(seq 1 "$tries"); do if curl -fsS --max-time 5 "$url" >/dev/null 2>&1; then log "$name ready" return 0 fi sleep 2 done log "$name not ready" return 1 } wait_http "http://localhost:8080/health" "RustFS" 25 wait_http "http://localhost:8081/healthz" "Symbols.Server" 25 log "Seeding bucket via RustFS S3-compatible API" # RustFS auto-creates buckets on first PUT, or use AWS CLI with S3 endpoint aws --endpoint-url http://localhost:8080 s3 mb s3://symbols 2>/dev/null || true log "Capture readiness endpoint" curl -fsS http://localhost:8081/healthz -o "$RUN_DIR/healthz.json" log "Smoke list request" curl -fsS http://localhost:8081/ -o "$RUN_DIR/root.html" || true echo "status=pass" > "$RUN_DIR/summary.txt"