name: Web App E2E Testing - Optimized on: pull_request: paths: - "web/**" workflow_dispatch: jobs: # 1. Build the frontend once build-frontend: runs-on: blacksmith-32vcpu-ubuntu-2204 outputs: build-artifact: web-build.tar.gz steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node.js (Blacksmith Cache) uses: useblacksmith/setup-node@v5 with: node-version: "22" - name: Mount NPM Cache uses: useblacksmith/stickydisk@v1 with: key: frontend-npm-${{ github.sha }} path: ~/.npm - name: Install Frontend Dependencies working-directory: ./web run: npm install - name: Build Frontend working-directory: ./web run: 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 - name: Archive Frontend Build working-directory: ./web run: tar -czf web-build.tar.gz .next - name: Upload Frontend Build uses: actions/upload-artifact@v4 with: name: web-build path: web/web-build.tar.gz # 2. Build the API Docker image once build-api: runs-on: blacksmith-32vcpu-ubuntu-2204 steps: - name: Checkout uses: actions/checkout@v4 - name: Build & Load API Docker Image uses: useblacksmith/build-push-action@v1 with: context: ./api file: ./api/Dockerfile push: false load: true tags: local-api-test:latest - name: Save API Image to TAR run: docker save local-api-test:latest -o api-image.tar - name: Upload API Image uses: actions/upload-artifact@v4 with: name: api-image path: api-image.tar # 3. Setup Supabase environment independently setup-supabase: runs-on: blacksmith-32vcpu-ubuntu-2204 environment: testing steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Supabase Environment uses: ./.github/actions/setup-test-environment # 4. Run tests in 4 parallel shards test: needs: [build-frontend, build-api, setup-supabase] runs-on: blacksmith-32vcpu-ubuntu-2204 environment: testing services: redis: image: redis ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node.js (Blacksmith Cache) uses: useblacksmith/setup-node@v5 with: node-version: "22" - name: Mount NPM Cache uses: useblacksmith/stickydisk@v1 with: key: tests-npm-${{ github.sha }} path: ~/.npm - name: Download Frontend Build uses: actions/download-artifact@v4 with: name: web-build - name: Extract Frontend Build run: | mkdir -p web/.next tar -xzf web-build.tar.gz -C web/ - name: Install Dependencies for Testing working-directory: ./web run: | npm install npx playwright install --with-deps - name: Download API Image uses: actions/download-artifact@v4 with: name: api-image - name: Load API Docker Image run: docker load -i api-image.tar - 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 RERANK_API_KEY='${{ secrets.GH_ACTIONS_COHERE_API_KEY }}' \ -e RERANK_MODEL='rerank-v3.5' \ -e RERANK_BASE_URL='https://api.cohere.com/v2/rerank' \ -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: | for i in {1..30}; do if curl -f http://localhost:3001/health; then exit 0 fi sleep 1 done echo "API did not become healthy." && exit 1 - name: Run Playwright Tests working-directory: ./web run: | npx playwright test env: CI: "true" DEBUG: "pw:api" timeout-minutes: 15 - name: Stop Supabase uses: ./.github/actions/stop-supabase if: always() - name: Cleanup API Container if: always() run: | docker stop local-api docker rm local-api