Skip to content

Commit d391e1a

Browse files
committed
Cache playwright browser
1 parent 986f85f commit d391e1a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,30 @@ jobs:
2424
- name: Install dependencies
2525
run: npm ci
2626

27-
- name: Install Playwright Browsers
27+
# https://github.com/microsoft/playwright/issues/7249#issuecomment-1385567519
28+
- name: Store Playwright's Version
29+
run: |
30+
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
31+
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
32+
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
33+
34+
- name: Cache Playwright Browsers for Playwright's Version
35+
id: cache-playwright-browsers
36+
uses: actions/cache@v4
37+
with:
38+
path: ~/.cache/ms-playwright
39+
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}
40+
41+
- name: Setup Playwright
42+
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
2843
run: npx playwright install --with-deps
2944

3045
- name: Run Playwright tests
3146
run: npm run e2e
47+
48+
- uses: actions/upload-artifact@v4
49+
if: ${{ !cancelled() }}
50+
with:
51+
name: playwright-report
52+
path: test-results/reports-ci
53+
retention-days: 30

config/playwright.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ export default defineConfig({
99
timeout: 60 * 1000,
1010
reuseExistingServer: !process.env.CI
1111
},
12+
workers: process.env.GITHUB_ACTIONS ? 1 : undefined,
13+
reporter: process.env.GITHUB_ACTIONS
14+
? [
15+
['list', { printSteps: true, forceColor: true }],
16+
['junit', { outputFile: '../test-results/reports-ci/results.xml' }],
17+
['json', { outputFile: '../test-results/reports-ci/results.json' }]
18+
]
19+
: 'list',
1220
projects: [
1321
{
1422
name: 'Chrome Desktop',

0 commit comments

Comments
 (0)