name: Test on: [push] jobs: unit-test: runs-on: test steps: - uses: actions/checkout@v4 - name: Install & Run unit tests run: cd frontend && npm ci && npx vitest run --reporter=verbose e2e-test: runs-on: test needs: unit-test timeout-minutes: 5 steps: - uses: actions/checkout@v4 - name: Install frontend deps run: cd frontend && npm ci - name: Install backend deps run: python3 -m venv /tmp/ci-venv && /tmp/ci-venv/bin/pip install -q -r backend/requirements.txt - name: E2E tests run: | # Dynamic ports to avoid conflicts BE_PORT=$(shuf -i 9000-9999 -n 1) FE_PORT=$(shuf -i 4000-4999 -n 1) DB_FILE="/tmp/ci_oil_test_${BE_PORT}.db" echo "Using backend=$BE_PORT frontend=$FE_PORT db=$DB_FILE" # Start backend DB_PATH="$DB_FILE" FRONTEND_DIR=/dev/null \ /tmp/ci-venv/bin/uvicorn backend.main:app --port $BE_PORT & BE_PID=$! # Start frontend with proxy to dynamic backend port (cd frontend && VITE_API_PORT=$BE_PORT npx vite --port $FE_PORT) & FE_PID=$! # Wait for both servers (max 30s, fail fast) READY=0 for i in $(seq 1 30); do if curl -sf http://localhost:$BE_PORT/api/oils > /dev/null 2>&1 && \ curl -sf http://localhost:$FE_PORT/ > /dev/null 2>&1; then echo "Both servers ready in ${i}s" READY=1 break fi sleep 1 done if [ "$READY" = "0" ]; then echo "ERROR: Servers failed to start within 30s" kill $BE_PID $FE_PID 2>/dev/null rm -f "$DB_FILE" exit 1 fi # Run core cypress specs with timeouts cd frontend npx cypress run --spec "\ cypress/e2e/recipe-detail.cy.js,\ cypress/e2e/oil-reference.cy.js,\ cypress/e2e/oil-data-integrity.cy.js,\ cypress/e2e/recipe-cost-parity.cy.js,\ cypress/e2e/category-modules.cy.js,\ cypress/e2e/notification-flow.cy.js,\ cypress/e2e/registration-flow.cy.js\ " --config "video=false,defaultCommandTimeout=5000,pageLoadTimeout=10000,baseUrl=http://localhost:$FE_PORT" EXIT_CODE=$? # Cleanup kill $BE_PID $FE_PID 2>/dev/null rm -f "$DB_FILE" exit $EXIT_CODE build-check: runs-on: test steps: - uses: actions/checkout@v4 - name: Build frontend run: cd frontend && npm ci && npm run build