feat(ci): enhance Playwright test sharding and caching

This commit is contained in:
taroj1205 2025-06-22 18:01:36 +12:00
parent c64b34cc59
commit dc30633bc3
No known key found for this signature in database
GPG key ID: 0FCB6CFFE0981AB7
3 changed files with 30 additions and 12 deletions

View file

@ -179,14 +179,10 @@ jobs:
retention-days: 1
playwright:
name: Playwright Tests (Shard ${{ matrix.shard }})
name: Playwright Tests
needs: [check_changes, setup, build]
if: ${{ needs.check_changes.outputs.exists == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v4
with:
@ -202,10 +198,8 @@ jobs:
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-playwright-shard-${{ matrix.shard }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-playwright-shard-${{ matrix.shard }}-
${{ runner.os }}-turbo-playwright-
key: ${{ runner.os }}-turbo-playwright-${{ github.sha }}
restore-keys: ${{ runner.os }}-turbo-playwright-
- name: Restore Astro Cache
uses: actions/cache@v4
@ -252,15 +246,15 @@ jobs:
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright Tests (Shard ${{ matrix.shard }}/4)
run: pnpm exec turbo run test:playwright -- --shard=${{ matrix.shard }}/4
- name: Run Playwright Tests (4 Shards)
run: pnpm exec turbo run test:playwright:shard1 test:playwright:shard2 test:playwright:shard3 test:playwright:shard4
timeout-minutes: 10
- name: Upload Playwright Report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-shard-${{ matrix.shard }}
name: playwright-report
path: playwright-report/
retention-days: 7

View file

@ -22,6 +22,10 @@
"test": "vitest run",
"test:coverage": "vitest --coverage",
"test:playwright": "playwright test --reporter=list",
"test:playwright:shard1": "playwright test --reporter=list --shard=1/4",
"test:playwright:shard2": "playwright test --reporter=list --shard=2/4",
"test:playwright:shard3": "playwright test --reporter=list --shard=3/4",
"test:playwright:shard4": "playwright test --reporter=list --shard=4/4",
"prepare": "lefthook install"
},
"dependencies": {

View file

@ -34,6 +34,26 @@
"cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"]
},
"test:playwright:shard1": {
"cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"]
},
"test:playwright:shard2": {
"cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"]
},
"test:playwright:shard3": {
"cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"]
},
"test:playwright:shard4": {
"cache": true,
"inputs": ["**/*.{ts,tsx,js,jsx,astro}"],
"outputs": ["playwright-report/**", "test-results/**"]
}
},
"ui": "tui"