Skip to content

Commit 7157b15

Browse files
authored
ci: cache playwright binary correctly (#8599)
1 parent 6234bcd commit 7157b15

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

.github/workflows/ci.yml

+19-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
# 7 GiB by default on GitHub, setting to 6 GiB
55
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
66
NODE_OPTIONS: --max-old-space-size=6144
7+
# install playwright binary manually (because pnpm only runs install script once)
8+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
79

810
on:
911
push:
@@ -38,10 +40,6 @@ jobs:
3840
node_version: 16
3941
fail-fast: false
4042

41-
env:
42-
# Install playwright's binray under node_modules so it will be cached together
43-
PLAYWRIGHT_BROWSERS_PATH: "0"
44-
4543
name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"
4644
steps:
4745
- name: Checkout
@@ -59,8 +57,24 @@ jobs:
5957
- name: Install deps
6058
run: pnpm install
6159

62-
# This could be removed when https://github.com/pnpm/pnpm/issues/4888 is resolved
60+
# Install playwright's binary under custom directory to cache
61+
- name: Set Playwright path (non-windows)
62+
if: runner.os != 'Windows'
63+
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
64+
- name: Set Playwright path (windows)
65+
if: runner.os == 'Windows'
66+
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
67+
68+
- name: Cache Playwright's binary
69+
uses: actions/cache@v3
70+
with:
71+
# Playwright removes unused browsers automatically
72+
# So does not need to add playwright version to key
73+
key: ${{ runner.os }}-playwright-bin-v1
74+
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
75+
6376
- name: Install Playwright
77+
# does not need to explictly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
6478
run: pnpm playwright install chromium
6579

6680
- name: Build
@@ -98,8 +112,6 @@ jobs:
98112

99113
- name: Install deps
100114
run: pnpm install
101-
env:
102-
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
103115

104116
- name: Build
105117
run: pnpm run build

0 commit comments

Comments
 (0)