|
| 1 | +name: E2E Tests |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | + |
| 8 | +jobs: |
| 9 | + e2e-tests: |
| 10 | + timeout-minutes: 15 |
| 11 | + runs-on: ubuntu-latest |
| 12 | + env: |
| 13 | + DATABASE_URL: "file:dev.sqlite" |
| 14 | + KEYCLOAK_ISSUER: "http://localhost:8080/realms/cs-club" |
| 15 | + KEYCLOAK_CLIENT_ID: "website" |
| 16 | + KEYCLOAK_CLIENT_SECRET: "secret" |
| 17 | + AUTH_SECRET: "secret" |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 20 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 21 | + with: |
| 22 | + node-version: lts/* |
| 23 | + - name: Install dependencies |
| 24 | + run: npm install -g pnpm@11 && pnpm install |
| 25 | + |
| 26 | + - name: Start Docker E2E Integration Services |
| 27 | + run: | |
| 28 | + docker compose -f docker-compose-dev.yml up -d keycloak redis |
| 29 | +
|
| 30 | + - name: Wait for Keycloak Service Health |
| 31 | + run: | |
| 32 | + echo "Waiting for Keycloak to boot and import realm..." |
| 33 | + for i in {1..30}; do |
| 34 | + if curl --fail -s http://localhost:8080/realms/cs-club >/dev/null; then |
| 35 | + echo "Keycloak is ready!" |
| 36 | + exit 0 |
| 37 | + fi |
| 38 | + echo "Keycloak not ready yet, sleeping 5s..." |
| 39 | + sleep 5 |
| 40 | + done |
| 41 | + echo "Keycloak failed to boot in time" |
| 42 | + docker compose -f docker-compose-dev.yml logs keycloak |
| 43 | + exit 1 |
| 44 | +
|
| 45 | + - name: Push Database Schema |
| 46 | + run: pnpm run db:push |
| 47 | + |
| 48 | + - name: Install Playwright Browsers |
| 49 | + run: pnpm exec playwright install --with-deps chromium |
| 50 | + |
| 51 | + - name: Run Playwright tests |
| 52 | + env: |
| 53 | + REDIS_URI: redis://localhost:6379 |
| 54 | + SKIP_ENV_VALIDATION: 'true' |
| 55 | + MOCK_SQUARE: 'true' |
| 56 | + NEXT_PUBLIC_PAYLOAD_URI: 'https://cms.csclub.org.au' |
| 57 | + run: pnpm test:e2e |
| 58 | + |
| 59 | + - name: Stop Docker Services |
| 60 | + if: always() |
| 61 | + run: | |
| 62 | + docker compose -f docker-compose-dev.yml down |
| 63 | +
|
| 64 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 65 | + if: ${{ !cancelled() }} |
| 66 | + with: |
| 67 | + name: playwright-report |
| 68 | + path: playwright-report/ |
| 69 | + retention-days: 30 |
0 commit comments