|
| 1 | +name: E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + paths: |
| 9 | + - 'static/js/**' |
| 10 | + - '_layouts/**' |
| 11 | + - '_includes/**' |
| 12 | + - 'tests/e2e/**' |
| 13 | + - 'playwright.config.js' |
| 14 | + - '.github/workflows/e2e-tests.yml' |
| 15 | + pull_request: |
| 16 | + paths: |
| 17 | + - 'static/js/**' |
| 18 | + - '_layouts/**' |
| 19 | + - '_includes/**' |
| 20 | + workflow_dispatch: |
| 21 | + inputs: |
| 22 | + browsers: |
| 23 | + description: 'Browsers to test (comma-separated: chromium,firefox,webkit)' |
| 24 | + required: false |
| 25 | + default: 'chromium' |
| 26 | + test-pattern: |
| 27 | + description: 'Test file pattern to run' |
| 28 | + required: false |
| 29 | + default: '**/*.spec.js' |
| 30 | + |
| 31 | +jobs: |
| 32 | + e2e-tests: |
| 33 | + name: E2E Tests - ${{ matrix.browser }} |
| 34 | + runs-on: ubuntu-latest |
| 35 | + |
| 36 | + strategy: |
| 37 | + fail-fast: false |
| 38 | + matrix: |
| 39 | + browser: [chromium, firefox, webkit] |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: 📂 Checkout repository |
| 43 | + uses: actions/checkout@v5 |
| 44 | + |
| 45 | + - name: 💎 Setup Ruby |
| 46 | + uses: ruby/setup-ruby@v1 |
| 47 | + with: |
| 48 | + ruby-version: '3.3' |
| 49 | + bundler-cache: true |
| 50 | + |
| 51 | + - name: 🟢 Setup Node.js |
| 52 | + uses: actions/setup-node@v4 |
| 53 | + with: |
| 54 | + node-version: '20' |
| 55 | + cache: 'npm' |
| 56 | + |
| 57 | + - name: 📦 Install dependencies |
| 58 | + run: | |
| 59 | + bundle install |
| 60 | + npm ci |
| 61 | +
|
| 62 | + - name: 🎭 Install Playwright browsers |
| 63 | + run: | |
| 64 | + npx playwright install --with-deps ${{ matrix.browser }} |
| 65 | +
|
| 66 | + - name: 🚀 Start Jekyll server (test mode for speed) |
| 67 | + run: | |
| 68 | + bundle exec jekyll serve --config _config.yml,_config.test.yml --incremental --detach --skip-initial-build |
| 69 | + env: |
| 70 | + JEKYLL_ENV: test |
| 71 | + |
| 72 | + - name: ⏳ Wait for server |
| 73 | + run: | |
| 74 | + npx wait-on http://localhost:4000 -t 30000 |
| 75 | +
|
| 76 | + - name: 🧪 Run E2E tests |
| 77 | + run: | |
| 78 | + npx playwright test --project=${{ matrix.browser }} |
| 79 | + env: |
| 80 | + CI: true |
| 81 | + BASE_URL: http://localhost:4000 |
| 82 | + |
| 83 | + - name: 📊 Upload test results |
| 84 | + if: always() |
| 85 | + uses: actions/upload-artifact@v3 |
| 86 | + with: |
| 87 | + name: playwright-report-${{ matrix.browser }} |
| 88 | + path: | |
| 89 | + playwright-report/ |
| 90 | + test-results/ |
| 91 | + retention-days: 7 |
| 92 | + |
| 93 | + - name: 📸 Upload screenshots |
| 94 | + if: failure() |
| 95 | + uses: actions/upload-artifact@v3 |
| 96 | + with: |
| 97 | + name: screenshots-${{ matrix.browser }} |
| 98 | + path: test-results/screenshots/ |
| 99 | + retention-days: 7 |
| 100 | + |
| 101 | + e2e-mobile: |
| 102 | + name: E2E Tests - Mobile |
| 103 | + runs-on: ubuntu-latest |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: 📂 Checkout repository |
| 107 | + uses: actions/checkout@v5 |
| 108 | + |
| 109 | + - name: 💎 Setup Ruby |
| 110 | + uses: ruby/setup-ruby@v1 |
| 111 | + with: |
| 112 | + ruby-version: '3.3' |
| 113 | + bundler-cache: true |
| 114 | + |
| 115 | + - name: 🟢 Setup Node.js |
| 116 | + uses: actions/setup-node@v4 |
| 117 | + with: |
| 118 | + node-version: '20' |
| 119 | + cache: 'npm' |
| 120 | + |
| 121 | + - name: 📦 Install dependencies |
| 122 | + run: | |
| 123 | + bundle install |
| 124 | + npm ci |
| 125 | +
|
| 126 | + - name: 🎭 Install Playwright browsers |
| 127 | + run: | |
| 128 | + npx playwright install --with-deps chromium webkit |
| 129 | +
|
| 130 | + - name: 🚀 Start Jekyll server (test mode for speed) |
| 131 | + run: | |
| 132 | + bundle exec jekyll serve --config _config.yml,_config.test.yml --incremental --detach --skip-initial-build |
| 133 | + env: |
| 134 | + JEKYLL_ENV: test |
| 135 | + |
| 136 | + - name: ⏳ Wait for server |
| 137 | + run: | |
| 138 | + npx wait-on http://localhost:4000 -t 30000 |
| 139 | +
|
| 140 | + - name: 📱 Run mobile E2E tests |
| 141 | + run: | |
| 142 | + npx playwright test --project=mobile-chrome --project=mobile-safari |
| 143 | + env: |
| 144 | + CI: true |
| 145 | + BASE_URL: http://localhost:4000 |
| 146 | + |
| 147 | + - name: 📊 Upload mobile test results |
| 148 | + if: always() |
| 149 | + uses: actions/upload-artifact@v3 |
| 150 | + with: |
| 151 | + name: playwright-report-mobile |
| 152 | + path: | |
| 153 | + playwright-report/ |
| 154 | + test-results/ |
| 155 | + retention-days: 7 |
| 156 | + |
| 157 | + visual-regression: |
| 158 | + name: Visual Regression Tests |
| 159 | + runs-on: ubuntu-latest |
| 160 | + if: github.event_name == 'pull_request' |
| 161 | + |
| 162 | + steps: |
| 163 | + - name: 📂 Checkout repository |
| 164 | + uses: actions/checkout@v5 |
| 165 | + |
| 166 | + - name: 💎 Setup Ruby |
| 167 | + uses: ruby/setup-ruby@v1 |
| 168 | + with: |
| 169 | + ruby-version: '3.3' |
| 170 | + bundler-cache: true |
| 171 | + |
| 172 | + - name: 🟢 Setup Node.js |
| 173 | + uses: actions/setup-node@v4 |
| 174 | + with: |
| 175 | + node-version: '20' |
| 176 | + cache: 'npm' |
| 177 | + |
| 178 | + - name: 📦 Install dependencies |
| 179 | + run: | |
| 180 | + bundle install |
| 181 | + npm ci |
| 182 | +
|
| 183 | + - name: 🎭 Install Playwright |
| 184 | + run: | |
| 185 | + npx playwright install --with-deps chromium |
| 186 | +
|
| 187 | + - name: 🚀 Start Jekyll server (test mode for speed) |
| 188 | + run: | |
| 189 | + bundle exec jekyll serve --config _config.yml,_config.test.yml --incremental --detach --skip-initial-build |
| 190 | + env: |
| 191 | + JEKYLL_ENV: test |
| 192 | + |
| 193 | + - name: ⏳ Wait for server |
| 194 | + run: | |
| 195 | + npx wait-on http://localhost:4000 -t 30000 |
| 196 | +
|
| 197 | + - name: 📸 Capture screenshots |
| 198 | + run: | |
| 199 | + npx playwright test --project=chromium --grep @visual |
| 200 | + env: |
| 201 | + CI: true |
| 202 | + BASE_URL: http://localhost:4000 |
| 203 | + |
| 204 | + - name: 🖼️ Upload visual diffs |
| 205 | + if: failure() |
| 206 | + uses: actions/upload-artifact@v3 |
| 207 | + with: |
| 208 | + name: visual-diffs |
| 209 | + path: test-results/visual-diffs/ |
| 210 | + retention-days: 7 |
| 211 | + |
| 212 | + report: |
| 213 | + name: Test Report |
| 214 | + runs-on: ubuntu-latest |
| 215 | + needs: [e2e-tests, e2e-mobile] |
| 216 | + if: always() |
| 217 | + |
| 218 | + steps: |
| 219 | + - name: 📂 Checkout repository |
| 220 | + uses: actions/checkout@v5 |
| 221 | + |
| 222 | + - name: 🟢 Setup Node.js |
| 223 | + uses: actions/setup-node@v4 |
| 224 | + with: |
| 225 | + node-version: '20' |
| 226 | + |
| 227 | + - name: 📥 Download all artifacts |
| 228 | + uses: actions/download-artifact@v3 |
| 229 | + with: |
| 230 | + path: all-reports |
| 231 | + |
| 232 | + - name: 📋 Merge test results |
| 233 | + run: | |
| 234 | + mkdir -p merged-report |
| 235 | + # Merge all test results |
| 236 | + find all-reports -name "*.xml" -exec cp {} merged-report/ \; |
| 237 | + find all-reports -name "*.json" -exec cp {} merged-report/ \; |
| 238 | +
|
| 239 | + - name: 💬 Comment PR with results |
| 240 | + if: github.event_name == 'pull_request' |
| 241 | + uses: actions/github-script@v7 |
| 242 | + with: |
| 243 | + script: | |
| 244 | + const fs = require('fs'); |
| 245 | + const path = require('path'); |
| 246 | +
|
| 247 | + let comment = '## 🎭 E2E Test Results\n\n'; |
| 248 | +
|
| 249 | + // Parse test results |
| 250 | + const reportFiles = fs.readdirSync('merged-report').filter(f => f.endsWith('.json')); |
| 251 | + let totalTests = 0; |
| 252 | + let passedTests = 0; |
| 253 | + let failedTests = 0; |
| 254 | + let skippedTests = 0; |
| 255 | +
|
| 256 | + reportFiles.forEach(file => { |
| 257 | + try { |
| 258 | + const data = JSON.parse(fs.readFileSync(path.join('merged-report', file), 'utf8')); |
| 259 | + if (data.stats) { |
| 260 | + totalTests += data.stats.expected || 0; |
| 261 | + passedTests += data.stats.passed || 0; |
| 262 | + failedTests += data.stats.failed || 0; |
| 263 | + skippedTests += data.stats.skipped || 0; |
| 264 | + } |
| 265 | + } catch (e) { |
| 266 | + console.error(`Failed to parse ${file}:`, e); |
| 267 | + } |
| 268 | + }); |
| 269 | +
|
| 270 | + comment += `| Browser | Status | Tests | Passed | Failed | Skipped |\n`; |
| 271 | + comment += `|---------|--------|-------|--------|--------|----------|\n`; |
| 272 | +
|
| 273 | + const browsers = ['chromium', 'firefox', 'webkit', 'mobile']; |
| 274 | + for (const browser of browsers) { |
| 275 | + const artifactExists = fs.existsSync(`all-reports/playwright-report-${browser}`); |
| 276 | + if (artifactExists) { |
| 277 | + const status = failedTests === 0 ? '✅' : '❌'; |
| 278 | + comment += `| ${browser} | ${status} | ${totalTests} | ${passedTests} | ${failedTests} | ${skippedTests} |\n`; |
| 279 | + } |
| 280 | + } |
| 281 | +
|
| 282 | + comment += '\n### 📊 Coverage Summary\n'; |
| 283 | + comment += '- Notification System: ✅ Tested\n'; |
| 284 | + comment += '- Countdown Timers: ✅ Tested\n'; |
| 285 | + comment += '- Conference Management: ✅ Tested\n'; |
| 286 | + comment += '- Search & Filter: ✅ Tested\n'; |
| 287 | +
|
| 288 | + if (failedTests > 0) { |
| 289 | + comment += '\n⚠️ **Some tests failed. Please check the artifacts for details.**\n'; |
| 290 | + } else { |
| 291 | + comment += '\n✅ **All E2E tests passed successfully!**\n'; |
| 292 | + } |
| 293 | +
|
| 294 | + // Find and update or create comment |
| 295 | + const { data: comments } = await github.rest.issues.listComments({ |
| 296 | + owner: context.repo.owner, |
| 297 | + repo: context.repo.repo, |
| 298 | + issue_number: context.issue.number, |
| 299 | + }); |
| 300 | +
|
| 301 | + const botComment = comments.find(comment => |
| 302 | + comment.user.type === 'Bot' && |
| 303 | + comment.body.includes('E2E Test Results') |
| 304 | + ); |
| 305 | +
|
| 306 | + if (botComment) { |
| 307 | + await github.rest.issues.updateComment({ |
| 308 | + owner: context.repo.owner, |
| 309 | + repo: context.repo.repo, |
| 310 | + comment_id: botComment.id, |
| 311 | + body: comment |
| 312 | + }); |
| 313 | + } else { |
| 314 | + await github.rest.issues.createComment({ |
| 315 | + owner: context.repo.owner, |
| 316 | + repo: context.repo.repo, |
| 317 | + issue_number: context.issue.number, |
| 318 | + body: comment |
| 319 | + }); |
| 320 | + } |
| 321 | +
|
| 322 | + - name: 📈 Upload to dashboard |
| 323 | + if: github.ref == 'refs/heads/main' |
| 324 | + continue-on-error: true |
| 325 | + run: | |
| 326 | + echo "Test results can be uploaded to a dashboard service here" |
0 commit comments