|
| 1 | +name: E2E Tests |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main] |
| 5 | + pull_request: |
| 6 | + branches: [main] |
| 7 | + workflow_call: |
| 8 | + # Allow this workflow to be called by other workflows |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + e2e-tests: |
| 16 | + name: End-to-End Tests |
| 17 | + runs-on: ubuntu-24.04 |
| 18 | + timeout-minutes: 15 |
| 19 | + container: |
| 20 | + image: mcr.microsoft.com/playwright:v1.55.0-jammy |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + pull-requests: write |
| 24 | + issues: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Setup Node.js |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version-file: '.nvmrc' |
| 34 | + cache-dependency-path: 'yarn.lock' |
| 35 | + cache: 'yarn' |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + run: yarn install |
| 39 | + |
| 40 | + - name: Build dependencies |
| 41 | + run: npx nx run-many -t ci:build |
| 42 | + |
| 43 | + - name: Run Playwright tests |
| 44 | + run: | |
| 45 | + cd packages/app |
| 46 | + yarn test:e2e |
| 47 | +
|
| 48 | + - name: Upload Playwright report |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + if: always() |
| 51 | + with: |
| 52 | + name: playwright-report |
| 53 | + path: packages/app/playwright-report/ |
| 54 | + retention-days: 30 |
| 55 | + |
| 56 | + - name: Upload test results |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + if: always() |
| 59 | + with: |
| 60 | + name: test-results |
| 61 | + path: packages/app/test-results/ |
| 62 | + retention-days: 30 |
| 63 | + |
| 64 | + - name: Comment PR with test results |
| 65 | + uses: actions/github-script@v7 |
| 66 | + if: always() && github.event_name == 'pull_request' |
| 67 | + with: |
| 68 | + script: | |
| 69 | + const fs = require('fs'); |
| 70 | + const path = require('path'); |
| 71 | +
|
| 72 | + try { |
| 73 | + const resultsPath = path.join('packages/app/test-results/results.json'); |
| 74 | + if (fs.existsSync(resultsPath)) { |
| 75 | + const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8')); |
| 76 | + const { stats } = results; |
| 77 | +
|
| 78 | + const total = stats.expected + stats.unexpected + stats.flaky + stats.skipped; |
| 79 | + const failed = stats.unexpected > 0; |
| 80 | +
|
| 81 | + const summary = failed |
| 82 | + ? `❌ **${stats.unexpected} test${stats.unexpected > 1 ? 's' : ''} failed**` |
| 83 | + : `✅ **All tests passed**`; |
| 84 | +
|
| 85 | + const body = `## E2E Test Results |
| 86 | + |
| 87 | + ${summary} • ${stats.expected} passed • ${stats.skipped} skipped • ${Math.round(stats.duration / 1000)}s |
| 88 | + |
| 89 | + ${failed ? ` |
| 90 | + <details> |
| 91 | + <summary>View Details</summary> |
| 92 | +
|
| 93 | + | Status | Count | |
| 94 | + |--------|-------| |
| 95 | + | ✅ Passed | ${stats.expected} | |
| 96 | + | ❌ Failed | ${stats.unexpected} | |
| 97 | + | ⚠️ Flaky | ${stats.flaky} | |
| 98 | + | ⏭️ Skipped | ${stats.skipped} | |
| 99 | +
|
| 100 | + </details> |
| 101 | +
|
| 102 | + [View full report →](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})` : ''}`; |
| 103 | +
|
| 104 | + github.rest.issues.createComment({ |
| 105 | + issue_number: context.issue.number, |
| 106 | + owner: context.repo.owner, |
| 107 | + repo: context.repo.repo, |
| 108 | + body: body |
| 109 | + }); |
| 110 | + } |
| 111 | + } catch (error) { |
| 112 | + console.log('Could not post test results:', error.message); |
| 113 | + } |
0 commit comments