name: Web App E2E Testing on: pull_request: paths: - "web/**" workflow_dispatch: jobs: test: runs-on: blacksmith-32vcpu-ubuntu-2204 environment: testing # Service containers services: # Redis needed by API redis: image: redis ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js (Blacksmith Cache) uses: useblacksmith/setup-node@v5 with: node-version: "20" - name: Mount NPM Cache (Sticky Disk) uses: useblacksmith/stickydisk@v1 with: key: ${{ github.repository }}-npm-cache # Unique key per repository path: ~/.npm - name: Mount node_modules (Sticky Disk) uses: useblacksmith/stickydisk@v1 with: key: ${{ github.repository }}-node-modules # Unique key per repository path: ./web/node_modules # Mount directly into the web directory's node_modules # --- Setup Supabase Environment --- - name: Setup Test Environment # Runs Supabase, migrations, seeding on host uses: ./.github/actions/setup-test-environment # Run API and Frontend builds in parallel - name: Frontend Install Dependencies and Build working-directory: ./web run: | echo "Installing frontend dependencies and building..." npm install npx playwright install --with-deps npm run build env: NEXT_PUBLIC_API_URL: http://localhost:3001 NEXT_PUBLIC_URL: http://localhost:3000 NEXT_PUBLIC_SUPABASE_URL: http://127.0.0.1:54321 NEXT_PUBLIC_SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODIzNDMwOTZ9.7UIsMFfHYKxH7bUJCRfxd6lr7CSXGF7UxtZQO10FMMo" NEXT_PUBLIC_WEB_SOCKET_URL: ws://localhost:3001 # --- Build API Docker Image with Blacksmith Caching --- - name: Build and Load API Docker Image uses: useblacksmith/build-push-action@v1 with: context: ./api file: ./api/Dockerfile push: false # Do not push, load locally for service container load: true # Load the image into the runner's Docker daemon tags: local-api-test:latest # Tag for the service definition # --- Start API Container Manually --- - name: Start API Container run: | docker run -d --name local-api -p 3001:3001 \ --network=host \ -e DATABASE_URL='postgres://postgres:postgres@127.0.0.1:54322/postgres' \ -e POOLER_URL='postgres://postgres:postgres@127.0.0.1:54322/postgres' \ -e REDIS_URL='redis://127.0.0.1:6379' \ -e JWT_SECRET='super-secret-jwt-token-with-at-least-32-characters-long' \ -e SUPABASE_URL='http://127.0.0.1:54321' \ -e SUPABASE_SERVICE_ROLE_KEY='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MjM0MzA5Nn0.EGgMpd9zvvHPCOq4DJRLwzJ1iS3GV4AEyzguXGcbEIY' \ -e ENVIRONMENT='development' \ -e BUSTER_URL='http://localhost:3000' \ -e BUSTER_WH_TOKEN='buster-wh-token' \ -e LOG_LEVEL='debug' \ -e PORT='3001' \ -e RUST_LOG='debug' \ -e OPENAI_API_KEY='${{ secrets.GH_ACTIONS_OPENAI_API_KEY }}' \ -e RESEND_API_KEY='${{ secrets.GH_ACTIONS_RESEND_API_KEY }}' \ -e COHERE_API_KEY='${{ secrets.GH_ACTIONS_COHERE_API_KEY }}' \ -e LLM_API_KEY='${{ secrets.GH_ACTIONS_LLM_API_KEY }}' \ -e LLM_BASE_URL='${{ secrets.GH_ACTIONS_LLM_BASE_URL }}' \ local-api-test:latest - name: Wait for API Health Check run: | echo "Waiting for API to be healthy..." for i in {1..30}; do # Wait up to 30 seconds if curl -f http://localhost:3001/health; then echo "API is healthy!" exit 0 fi sleep 1 done echo "API did not become healthy in time." exit 1 # Debug step to check dependencies and validate services - name: Debug - Verify Environment run: | echo "Verifying API service:" curl -v http://localhost:3001/health || echo "Failed to connect to API" echo "Verifying Supabase service:" curl -v http://127.0.0.1:54321/health || echo "Failed to connect to Supabase" echo "Checking make script content for 'start-fast':" cat web/Makefile | grep -A 10 "start-fast" - name: Run Frontend E2E Tests with xvfb working-directory: ./web run: | echo "Running web E2E tests..." npx playwright test env: NEXT_PUBLIC_API_URL: http://localhost:3001 NEXT_PUBLIC_URL: http://localhost:3000 NEXT_PUBLIC_SUPABASE_URL: http://127.0.0.1:54321 NEXT_PUBLIC_SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODIzNDMwOTZ9.7UIsMFfHYKxH7bUJCRfxd6lr7CSXGF7UxtZQO10FMMo" NEXT_PUBLIC_WEB_SOCKET_URL: ws://localhost:3001 CI: "true" DEBUG: "pw:api" timeout-minutes: 15 - name: Stop Supabase # Use the cleanup action uses: ./.github/actions/stop-supabase if: always() # Ensure Supabase is stopped even if tests fail - name: Stop API Container # Cleanup manually started container if: always() run: docker stop local-api && docker rm local-api