Skip to content

Commit 9377bd7

Browse files
committed
implement sharding in CI
1 parent 3cd8513 commit 9377bd7

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

.github/workflows/playwright.yml

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ jobs:
88
test:
99
timeout-minutes: 60
1010
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
shard: [1, 2]
1115
services:
1216
falkordb:
1317
image: falkordb/falkordb:latest
@@ -32,10 +36,61 @@ jobs:
3236
run: |
3337
npm install
3438
npm run build
35-
NEXTAUTH_SECRET=SECRET npm start & npx playwright test --reporter=dot,list
39+
NEXTAUTH_SECRET=SECRET npm start &
40+
npx playwright test --shard=${{ matrix.shard }}/2 --reporter=dot,list,json
3641
- uses: actions/upload-artifact@v4
3742
if: ${{ !cancelled() }}
3843
with:
39-
name: playwright-report
44+
name: playwright-report-shard-${{ matrix.shard }}
4045
path: playwright-report/
4146
retention-days: 30
47+
- uses: actions/upload-artifact@v4
48+
if: ${{ !cancelled() }}
49+
with:
50+
name: test-results-shard-${{ matrix.shard }}
51+
path: test-results/
52+
retention-days: 30
53+
54+
merge-reports:
55+
if: ${{ !cancelled() }}
56+
needs: [test]
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: actions/setup-node@v4
61+
with:
62+
node-version: lts/*
63+
- name: Install dependencies
64+
run: npm ci
65+
- name: Download all test results
66+
uses: actions/download-artifact@v4
67+
with:
68+
path: all-test-results
69+
pattern: test-results-shard-*
70+
- name: Download all reports
71+
uses: actions/download-artifact@v4
72+
with:
73+
path: all-reports
74+
pattern: playwright-report-shard-*
75+
- name: Merge test results
76+
run: |
77+
# Create combined results directory
78+
mkdir -p combined-results
79+
80+
# Merge JSON results
81+
npx playwright merge-reports --reporter=html,json all-reports/playwright-report-shard-*/
82+
83+
# Move merged report to combined directory
84+
mv playwright-report combined-results/
85+
86+
# Create a summary of all test results
87+
echo "## Test Results Summary" > combined-results/summary.md
88+
echo "Total shards: 2" >> combined-results/summary.md
89+
echo "Workers per shard: 2" >> combined-results/summary.md
90+
echo "Generated on: $(date)" >> combined-results/summary.md
91+
- name: Upload combined report
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: combined-playwright-report
95+
path: combined-results/
96+
retention-days: 30

playwright.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ export default defineConfig({
2222
/* Opt out of parallel tests on CI. */
2323
workers: process.env.CI ? 2 : undefined,
2424
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
25-
reporter: 'html',
25+
reporter: process.env.CI ? [
26+
['dot'],
27+
['list'],
28+
['json', { outputFile: 'test-results/results.json' }],
29+
['html', { open: 'never', outputFolder: 'playwright-report' }]
30+
] : 'html',
2631
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2732
use: {
2833
/* Base URL to use in actions like `await page.goto('/')`. */

0 commit comments

Comments
 (0)