name: End-to-End Functional Tests on: push: branches: [ main, develop ] pull_request: branches: [ main ] jobs: functional-testing: runs-on: ubuntu-latest services: # Optional: If FastAPI app requires a database like PostgreSQL, # spin it up here as a service container. steps: # 1. Checkout the repository code - name: Checkout Code uses: actions/checkout@v4 # 2. Set up Python for the FastAPI Backend - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.12' cache: 'pip' # 3. Install Backend Dependencies and Start FastAPI in the background - name: Install & Start FastAPI Backend run: | pip install -r backend/requirements.txt cd backend uvicorn main:app --host 127.0.0.1 --port 8000 & # Adjust the paths and start commands to match backend folder structure # 4. Set up Node.js for the Angular Frontend - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' cache-dependency-path: frontend/package-lock.json # 5. Install Frontend Dependencies - name: Install Frontend Dependencies run: | cd frontend npm ci # 6. Install E2E Testing Browser Binaries (Playwright or Cypress assumed here) - name: Install Test Browser Dependencies run: | cd frontend npx playwright install --with-deps # Note: Swap out if using Cypress (e.g., npx cypress install) # 7. Start Angular Server in the Background - name: Start Angular Frontend run: | cd frontend npm run start -- --port 4200 & # 8. Wait for both servers to be fully live before starting tests - name: Wait for Services to be Ready run: | echo "Waiting for backend..." timeout 30s bash -c 'until curl -s http://127.0.0 > /dev/null; do sleep 1; done' echo "Waiting for frontend..." timeout 30s bash -c 'until curl -s http://127.0.0.1:4200 > /dev/null; do sleep 1; done' # 9. Execute your Functional/E2E Tests - name: Run Functional Tests run: | cd frontend npm run test:functional env: # Pass any base URLs or environment variables required by your tests BASE_URL: http://127.0.0.1:4200 API_URL: http://127.0.0.1:8000 # 10. Upload test results (e.g., videos, screenshots, or logs) if tests fail - name: Upload Test Artifacts if: failure() uses: actions/upload-artifact@v4 with: name: functional-test-failures path: | frontend/playwright-report/ frontend/cypress/screenshots/ retention-days: 5