|
71 | 71 | - name: Test (Vitest, single run + coverage thresholds) |
72 | 72 | run: npx ng test --watch=false |
73 | 73 |
|
| 74 | + |
| 75 | + # ──────────────────────── E2E (Playwright) ──────────────────────── |
| 76 | + e2e: |
| 77 | + name: e2e (Playwright) |
| 78 | + runs-on: ubuntu-latest |
| 79 | + services: |
| 80 | + postgres: |
| 81 | + image: postgres:16 |
| 82 | + env: |
| 83 | + POSTGRES_USER: postgres |
| 84 | + POSTGRES_PASSWORD: postgres |
| 85 | + POSTGRES_DB: docanalytics |
| 86 | + ports: |
| 87 | + - 5432:5432 |
| 88 | + options: >- |
| 89 | + --health-cmd "pg_isready -U postgres" |
| 90 | + --health-interval 10s |
| 91 | + --health-timeout 5s |
| 92 | + --health-retries 5 |
| 93 | + steps: |
| 94 | + - name: Checkout |
| 95 | + uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - name: Setup .NET 10 |
| 98 | + uses: actions/setup-dotnet@v4 |
| 99 | + with: |
| 100 | + dotnet-version: '10.0.x' |
| 101 | + |
| 102 | + - name: Setup Node 22 |
| 103 | + uses: actions/setup-node@v4 |
| 104 | + with: |
| 105 | + node-version: '22' |
| 106 | + cache: npm |
| 107 | + cache-dependency-path: docanalytics-web/package-lock.json |
| 108 | + |
| 109 | + - name: Trust dev HTTPS cert (API serves https on :7001) |
| 110 | + run: dotnet dev-certs https |
| 111 | + |
| 112 | + - name: Restore + build API (so startup is fast) |
| 113 | + run: | |
| 114 | + dotnet restore DocAnalytics.slnx |
| 115 | + dotnet build DocAnalytics.Api -c Release --no-restore |
| 116 | +
|
| 117 | + - name: Install web dependencies |
| 118 | + working-directory: docanalytics-web |
| 119 | + run: npm ci |
| 120 | + |
| 121 | + - name: Install Playwright browsers |
| 122 | + working-directory: docanalytics-web |
| 123 | + run: npx playwright install --with-deps |
| 124 | + |
| 125 | + - name: Start API and run Playwright E2E |
| 126 | + working-directory: docanalytics-web |
| 127 | + env: |
| 128 | + ASPNETCORE_ENVIRONMENT: Development |
| 129 | + ConnectionStrings__Default: "Host=localhost;Port=5432;Database=docanalytics;Username=postgres;Password=postgres" |
| 130 | + Jwt__Key: ${{ secrets.E2E_JWT_KEY }} |
| 131 | + CI: 'true' |
| 132 | + run: | |
| 133 | + set -e |
| 134 | + # Start the API in the background WITHIN this step so it stays alive |
| 135 | + # while Playwright runs (background procs are killed at step end). |
| 136 | + ( cd .. && dotnet run --project DocAnalytics.Api -c Release --no-build > api.log 2>&1 & ) |
| 137 | + echo "Waiting for API on https://localhost:7001 ..." |
| 138 | + up="" |
| 139 | + for i in $(seq 1 90); do |
| 140 | + if curl -sk https://localhost:7001/health >/dev/null 2>&1; then up=1; echo "API is up"; break; fi |
| 141 | + sleep 2 |
| 142 | + done |
| 143 | + if [ -z "$up" ]; then echo "API did not start"; cat ../api.log || true; exit 1; fi |
| 144 | + npx playwright test |
| 145 | +
|
| 146 | + - name: Upload Playwright report |
| 147 | + if: ${{ !cancelled() }} |
| 148 | + uses: actions/upload-artifact@v4 |
| 149 | + with: |
| 150 | + name: playwright-report |
| 151 | + path: docanalytics-web/playwright-report |
| 152 | + retention-days: 7 |
| 153 | + |
| 154 | + |
| 155 | + |
74 | 156 | # ──────────────────────── DevSecOps (scans) ──────────────────────── |
75 | 157 | devsecops: |
76 | 158 | name: devsecops (secrets + deps + image scan) |
|
0 commit comments