|
| 1 | +name: E2E Smoke Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main, develop] |
| 8 | + types: [opened, synchronize, reopened] |
| 9 | + |
| 10 | +jobs: |
| 11 | + e2e-smoke-tests: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup Node.js |
| 19 | + uses: actions/setup-node@v4 |
| 20 | + with: |
| 21 | + node-version: '18' |
| 22 | + cache: 'npm' |
| 23 | + cache-dependency-path: frontend/package-lock.json |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + working-directory: ./frontend |
| 27 | + run: npm ci |
| 28 | + |
| 29 | + - name: Install Playwright browsers |
| 30 | + working-directory: ./frontend |
| 31 | + run: npx playwright install --with chromium |
| 32 | + |
| 33 | + - name: Build application |
| 34 | + working-directory: ./frontend |
| 35 | + run: npm run build |
| 36 | + |
| 37 | + - name: Run E2E smoke tests |
| 38 | + working-directory: ./frontend |
| 39 | + run: npm run test:e2e:smoke:ci |
| 40 | + env: |
| 41 | + BASE_URL: http://localhost:3000 |
| 42 | + |
| 43 | + - name: Upload test results |
| 44 | + if: always() |
| 45 | + uses: actions/upload-artifact@v4 |
| 46 | + with: |
| 47 | + name: playwright-report |
| 48 | + path: frontend/playwright-report/ |
| 49 | + retention-days: 30 |
| 50 | + |
| 51 | + - name: Upload test videos |
| 52 | + if: failure() |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + with: |
| 55 | + name: playwright-videos |
| 56 | + path: frontend/test-results/ |
| 57 | + retention-days: 7 |
| 58 | + |
| 59 | + - name: Comment PR with test results |
| 60 | + if: github.event_name == 'pull_request' |
| 61 | + uses: actions/github-script@v7 |
| 62 | + with: |
| 63 | + script: | |
| 64 | + const fs = require('fs'); |
| 65 | + const path = './frontend/playwright-report/results.json'; |
| 66 | + |
| 67 | + let testResults = { |
| 68 | + passed: 0, |
| 69 | + failed: 0, |
| 70 | + total: 0, |
| 71 | + duration: 0 |
| 72 | + }; |
| 73 | + |
| 74 | + // Try to read test results |
| 75 | + if (fs.existsSync(path)) { |
| 76 | + const data = fs.readFileSync(path, 'utf8'); |
| 77 | + testResults = JSON.parse(data); |
| 78 | + } |
| 79 | + |
| 80 | + const comment = ` |
| 81 | + ## 🧪 E2E Smoke Test Results |
| 82 | + |
| 83 | + - **Total Tests**: ${testResults.total || 0} |
| 84 | + - **Passed**: ${testResults.passed || 0} |
| 85 | + - **Failed**: ${testResults.failed || 0} |
| 86 | + - **Duration**: ${Math.round((testResults.duration || 0) / 1000)}s |
| 87 | + |
| 88 | + ${testResults.failed > 0 ? '⚠️ Some E2E tests failed. Please check the test results for details.' : '✅ All E2E smoke tests passed!'} |
| 89 | + |
| 90 | + [📊 View Test Report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 91 | + `; |
| 92 | + |
| 93 | + github.rest.issues.createComment({ |
| 94 | + issue_number: context.issue.number, |
| 95 | + owner: context.repo.owner, |
| 96 | + repo: context.repo.repo, |
| 97 | + body: comment |
| 98 | + }); |
| 99 | + |
| 100 | + e2e-smoke-tests-mobile: |
| 101 | + runs-on: ubuntu-latest |
| 102 | + |
| 103 | + steps: |
| 104 | + - name: Checkout repository |
| 105 | + uses: actions/checkout@v4 |
| 106 | + |
| 107 | + - name: Setup Node.js |
| 108 | + uses: actions/setup-node@v4 |
| 109 | + with: |
| 110 | + node-version: '18' |
| 111 | + cache: 'npm' |
| 112 | + cache-dependency-path: frontend/package-lock.json |
| 113 | + |
| 114 | + - name: Install dependencies |
| 115 | + working-directory: ./frontend |
| 116 | + run: npm ci |
| 117 | + |
| 118 | + - name: Install Playwright browsers |
| 119 | + working-directory: ./frontend |
| 120 | + run: npx playwright install --with chromium |
| 121 | + |
| 122 | + - name: Build application |
| 123 | + working-directory: ./frontend |
| 124 | + run: npm run build |
| 125 | + |
| 126 | + - name: Run mobile E2E smoke tests |
| 127 | + working-directory: ./frontend |
| 128 | + run: npx playwright test smoke-tests.spec.ts --project=mobile-chrome --reporter=list |
| 129 | + env: |
| 130 | + BASE_URL: http://localhost:3000 |
| 131 | + |
| 132 | + - name: Upload mobile test results |
| 133 | + if: always() |
| 134 | + uses: actions/upload-artifact@v4 |
| 135 | + with: |
| 136 | + name: playwright-mobile-report |
| 137 | + path: frontend/playwright-report/ |
| 138 | + retention-days: 30 |
0 commit comments