|
1 | 1 | name: Playwright Tests |
| 2 | + |
2 | 3 | on: |
3 | 4 | push: |
4 | | - branches: [ main, master ] |
| 5 | + branches: [ main, master, develop ] |
5 | 6 | pull_request: |
6 | | - branches: [ main, master ] |
| 7 | + branches: [ main, master, develop ] |
| 8 | + workflow_dispatch: |
| 9 | + |
7 | 10 | jobs: |
8 | 11 | test: |
| 12 | + name: Run Playwright Tests |
9 | 13 | timeout-minutes: 60 |
10 | 14 | runs-on: ubuntu-latest |
| 15 | + |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + project: [chromium, firefox, webkit] |
| 20 | + |
11 | 21 | steps: |
12 | | - - uses: actions/checkout@v4 |
13 | | - - uses: actions/setup-node@v4 |
14 | | - with: |
15 | | - node-version: lts/* |
16 | | - - name: Install dependencies |
17 | | - run: npm ci |
18 | | - - name: Install Playwright Browsers |
19 | | - run: npx playwright install --with-deps |
20 | | - - name: Run Playwright tests |
21 | | - run: npx playwright test |
22 | | - - uses: actions/upload-artifact@v4 |
23 | | - if: ${{ !cancelled() }} |
24 | | - with: |
25 | | - name: playwright-report |
26 | | - path: playwright-report/ |
27 | | - retention-days: 30 |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Setup Node.js |
| 26 | + uses: actions/setup-node@v4 |
| 27 | + with: |
| 28 | + node-version: '20' |
| 29 | + cache: 'npm' |
| 30 | + |
| 31 | + - name: Install dependencies |
| 32 | + run: npm ci |
| 33 | + |
| 34 | + - name: Install Playwright Browsers |
| 35 | + run: npx playwright install --with-deps ${{ matrix.project }} |
| 36 | + |
| 37 | + - name: Run Playwright tests |
| 38 | + run: npx playwright test --project=${{ matrix.project }} |
| 39 | + env: |
| 40 | + CI: true |
| 41 | + |
| 42 | + - name: Upload HTML Report |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + if: always() |
| 45 | + with: |
| 46 | + name: playwright-report-${{ matrix.project }} |
| 47 | + path: playwright-report/ |
| 48 | + retention-days: 30 |
| 49 | + |
| 50 | + - name: Upload Test Artifacts (on failure) |
| 51 | + uses: actions/upload-artifact@v4 |
| 52 | + if: failure() |
| 53 | + with: |
| 54 | + name: test-artifacts-${{ matrix.project }} |
| 55 | + path: | |
| 56 | + test-results/ |
| 57 | + playwright-report/ |
| 58 | + retention-days: 30 |
| 59 | + |
| 60 | + - name: Upload JUnit Results |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + if: always() |
| 63 | + with: |
| 64 | + name: junit-results-${{ matrix.project }} |
| 65 | + path: test-results/junit.xml |
| 66 | + retention-days: 30 |
| 67 | + |
| 68 | + report: |
| 69 | + name: Publish Test Report |
| 70 | + needs: test |
| 71 | + runs-on: ubuntu-latest |
| 72 | + if: always() |
| 73 | + |
| 74 | + steps: |
| 75 | + - name: Download all artifacts |
| 76 | + uses: actions/download-artifact@v4 |
| 77 | + with: |
| 78 | + path: all-reports |
| 79 | + |
| 80 | + - name: Publish Test Report |
| 81 | + uses: dorny/test-reporter@v1 |
| 82 | + if: always() |
| 83 | + with: |
| 84 | + name: Playwright Test Results |
| 85 | + path: 'all-reports/junit-results-*/junit.xml' |
| 86 | + reporter: java-junit |
| 87 | + fail-on-error: false |
| 88 | + |
| 89 | + comment-pr: |
| 90 | + name: Comment on PR |
| 91 | + needs: test |
| 92 | + runs-on: ubuntu-latest |
| 93 | + if: github.event_name == 'pull_request' && always() |
| 94 | + permissions: |
| 95 | + pull-requests: write |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Comment test results on PR |
| 99 | + uses: actions/github-script@v7 |
| 100 | + with: |
| 101 | + script: | |
| 102 | + let comment = '## 🎭 Playwright Test Results\n\n'; |
| 103 | + comment += '| Browser | Status |\n'; |
| 104 | + comment += '|---------|--------|\n'; |
| 105 | +
|
| 106 | + const browsers = ['chromium', 'firefox', 'webkit']; |
| 107 | + const status = '${{ needs.test.result }}' === 'success' ? '✅ Passed' : '❌ Failed'; |
| 108 | +
|
| 109 | + for (const browser of browsers) { |
| 110 | + comment += `| ${browser} | ${status} |\n`; |
| 111 | + } |
| 112 | +
|
| 113 | + comment += '\n📊 [View detailed report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})'; |
| 114 | +
|
| 115 | + github.rest.issues.createComment({ |
| 116 | + issue_number: context.issue.number, |
| 117 | + owner: context.repo.owner, |
| 118 | + repo: context.repo.repo, |
| 119 | + body: comment |
| 120 | + }); |
0 commit comments