#!/bin/bash set -e cd "$(dirname "$0")/.." # Cleanup function to kill background processes cleanup() { kill $BACKEND_PID 2>/dev/null || true kill $WORKER_PID 2>/dev/null || true } # Ensure cleanup runs on exit (normal, error, or interrupt) trap cleanup EXIT # Load environment variables if .env exists if [ -f .env ]; then set -a source .env set +a fi # Kill any existing backend pkill -f "uvicorn main:app" 2>/dev/null || true sleep 1 # Seed the database with roles and test users cd backend echo "Seeding database..." uv run python seed.py cd .. # Start backend (SECRET_KEY should be set via .envrc or environment) cd backend uv run uvicorn main:app --port 8000 --log-level warning & BACKEND_PID=$! # Start worker for job processing uv run python worker.py & WORKER_PID=$! cd .. # Wait for backend sleep 2 # Generate API types from OpenAPI schema echo "Generating API types..." cd frontend npm run generate-api-types cd .. # Run tests (suppress Node.js color warnings) # If TEST argument is provided, use it as a file pattern cd frontend if [ -n "$1" ]; then NODE_NO_WARNINGS=1 npx playwright test "$1" else NODE_NO_WARNINGS=1 npm run test:e2e fi EXIT_CODE=$? # Cleanup is handled by trap EXIT exit $EXIT_CODE