name: UI - E2E Tests on: pull_request: branches: - master - "v5.*" paths: - '.github/workflows/ui-e2e-tests.yml' - 'ui/**' jobs: e2e-tests: if: github.repository == 'prowler-cloud/prowler' runs-on: ubuntu-latest env: AUTH_SECRET: 'fallback-ci-secret-for-testing' AUTH_TRUST_HOST: true NEXTAUTH_URL: 'http://localhost:3000' NEXT_PUBLIC_API_BASE_URL: 'http://localhost:8080/api/v1' E2E_NEW_PASSWORD: ${{ secrets.E2E_NEW_PASSWORD }} steps: - name: Checkout repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Fix API data directory permissions run: docker run --rm -v $(pwd)/_data/api:/data alpine chown -R 1000:1000 /data - name: Start API services run: | # Override docker-compose image tag to use latest instead of stable # This overrides any PROWLER_API_VERSION set in .env file export PROWLER_API_VERSION=latest echo "Using PROWLER_API_VERSION=${PROWLER_API_VERSION}" docker compose up -d api worker worker-beat - name: Wait for API to be ready run: | echo "Waiting for prowler-api..." timeout=150 # 5 minutes max elapsed=0 while [ $elapsed -lt $timeout ]; do if curl -s ${NEXT_PUBLIC_API_BASE_URL}/docs >/dev/null 2>&1; then echo "Prowler API is ready!" exit 0 fi echo "Waiting for prowler-api... (${elapsed}s elapsed)" sleep 5 elapsed=$((elapsed + 5)) done echo "Timeout waiting for prowler-api to start" exit 1 - name: Load database fixtures for E2E tests run: | docker compose exec -T api sh -c ' echo "Loading all fixtures from api/fixtures/dev/..." for fixture in api/fixtures/dev/*.json; do if [ -f "$fixture" ]; then echo "Loading $fixture" poetry run python manage.py loaddata "$fixture" --database admin fi done echo "All database fixtures loaded successfully!" ' - name: Setup Node.js environment uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: node-version: '20.x' cache: 'npm' cache-dependency-path: './ui/package-lock.json' - name: Install UI dependencies working-directory: ./ui run: npm ci - name: Build UI application working-directory: ./ui run: npm run build - name: Cache Playwright browsers uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 id: playwright-cache with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('ui/package-lock.json') }} restore-keys: | ${{ runner.os }}-playwright- - name: Install Playwright browsers working-directory: ./ui if: steps.playwright-cache.outputs.cache-hit != 'true' run: npm run test:e2e:install - name: Run E2E tests working-directory: ./ui run: npm run test:e2e - name: Upload test reports uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 if: failure() with: name: playwright-report path: ui/playwright-report/ retention-days: 30 - name: Cleanup services if: always() run: | echo "Shutting down services..." docker compose down -v || true echo "Cleanup completed"