Skip to content

Commit 7eb95ee

Browse files
mydeaclaude
andcommitted
ci: Install Playwright in the background in more places
The install-playwright action gets a `part` input, so the system dependencies and the browsers can install as two parallel background steps. Browser integration and loader tests now install Playwright while the dependency cache restores, and E2E jobs start the install right after the artifact downloads, before setting up pnpm, Node and other runtimes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9a87a66 commit 7eb95ee

3 files changed

Lines changed: 147 additions & 68 deletions

File tree

‎.github/actions/install-playwright/action.yml‎

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ inputs:
99
'The directory whose package.json declares the `@playwright/test` version to install. Nothing is installed if it
1010
does not depend on `@playwright/test`.'
1111
required: true
12+
part:
13+
description:
14+
'What to install: `all`, `browsers` or `system-deps`. `browsers` and `system-deps` together install the same as
15+
`all`, and can run as two background steps in parallel.'
16+
default: 'all'
1217

1318
runs:
1419
using: 'composite'
@@ -29,35 +34,46 @@ runs:
2934
- name: Restore cached playwright binaries
3035
uses: actions/cache/restore@v6.1.0
3136
id: playwright-cache
32-
if: steps.playwright-version.outputs.version != ''
37+
if: steps.playwright-version.outputs.version != '' && inputs.part != 'system-deps'
3338
with:
3439
path: |
3540
~/.cache/ms-playwright
3641
# Bump the iteration when bumping runner images to use a new cache
3742
key: playwright-${{ runner.os }}-iteration-1-${{ steps.playwright-version.outputs.version }}
3843

3944
# We always install all browsers, if uncached
40-
- name: Install Playwright dependencies (uncached)
45+
- name: Install Playwright browsers (uncached)
4146
env:
47+
PART: ${{ inputs.part }}
4248
PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.version }}
43-
run: npx -y "playwright@$PLAYWRIGHT_VERSION" install chromium webkit firefox --with-deps
44-
if: steps.playwright-version.outputs.version != '' && steps.playwright-cache.outputs.cache-hit != 'true'
49+
run: |
50+
if [ "$PART" = all ]; then
51+
npx -y "playwright@$PLAYWRIGHT_VERSION" install chromium webkit firefox --with-deps
52+
else
53+
# A separate npm cache, so this `npx` doesn't race the one installing the system deps in parallel.
54+
npm_config_cache="$RUNNER_TEMP/playwright-npm-cache" npx -y "playwright@$PLAYWRIGHT_VERSION" install chromium webkit firefox
55+
fi
56+
if:
57+
steps.playwright-version.outputs.version != '' && inputs.part != 'system-deps' &&
58+
steps.playwright-cache.outputs.cache-hit != 'true'
4559
shell: bash
4660

47-
- name: Install Playwright system dependencies only (cached)
61+
- name: Install Playwright system dependencies
4862
env:
4963
PLAYWRIGHT_BROWSERS: ${{ inputs.browsers || 'chromium webkit firefox' }}
5064
PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.version }}
5165
run: npx -y "playwright@$PLAYWRIGHT_VERSION" install-deps "$PLAYWRIGHT_BROWSERS"
52-
if: steps.playwright-version.outputs.version != '' && steps.playwright-cache.outputs.cache-hit == 'true'
66+
if:
67+
steps.playwright-version.outputs.version != '' && (inputs.part == 'system-deps' || (inputs.part == 'all' &&
68+
steps.playwright-cache.outputs.cache-hit == 'true'))
5369
shell: bash
5470

5571
# Only store cache on develop branch
5672
- name: Store cached playwright binaries
5773
uses: actions/cache/save@v6.1.0
5874
if:
59-
steps.playwright-version.outputs.version != '' && github.event_name == 'push' && github.ref ==
60-
'refs/heads/develop'
75+
steps.playwright-version.outputs.version != '' && inputs.part != 'system-deps' && github.event_name == 'push' &&
76+
github.ref == 'refs/heads/develop'
6177
with:
6278
path: |
6379
~/.cache/ms-playwright

‎.github/actions/restore-cache/action.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
dependency_cache_key:
66
description: 'The dependency cache key'
77
required: true
8+
restore-build-output:
9+
description:
10+
'Whether to download the build output artifact. Disable it to download the artifact in a separate step.'
11+
default: 'true'
812

913
runs:
1014
using: 'composite'
@@ -17,6 +21,7 @@ runs:
1721
key: ${{ inputs.dependency_cache_key }}
1822

1923
- name: Restore build artifacts
24+
if: inputs.restore-build-output == 'true'
2025
uses: actions/download-artifact@v7
2126
with:
2227
name: build-output

‎.github/workflows/build.yml‎

Lines changed: 118 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -671,22 +671,42 @@ jobs:
671671
uses: actions/setup-node@v7
672672
with:
673673
node-version-file: 'package.json'
674-
- name: Restore caches
675-
uses: ./.github/actions/restore-cache
674+
- name: Restore build artifacts
675+
uses: actions/download-artifact@v8
676676
with:
677-
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
677+
name: build-output
678678

679679
- name: Restore build bundle artifacts
680680
uses: actions/download-artifact@v8
681681
with:
682682
name: build-bundle-output
683683
path: ${{ env.BUNDLE_ARTIFACT_DOWNLOAD_PATH }}
684684

685-
- name: Install Playwright
685+
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
686+
- name: Install Playwright browsers
687+
id: install-playwright-browsers
688+
background: true
689+
uses: ./.github/actions/install-playwright
690+
with:
691+
cwd: dev-packages/browser-integration-tests
692+
part: browsers
693+
694+
- name: Install Playwright system dependencies
695+
id: install-playwright-deps
696+
background: true
686697
uses: ./.github/actions/install-playwright
687698
with:
688699
browsers: ${{ matrix.project }}
689700
cwd: dev-packages/browser-integration-tests
701+
part: system-deps
702+
703+
- name: Restore caches
704+
uses: ./.github/actions/restore-cache
705+
with:
706+
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
707+
restore-build-output: 'false'
708+
709+
- wait: [install-playwright-browsers, install-playwright-deps]
690710

691711
- name: Run Playwright tests
692712
env:
@@ -734,22 +754,42 @@ jobs:
734754
uses: actions/setup-node@v7
735755
with:
736756
node-version-file: 'package.json'
737-
- name: Restore caches
738-
uses: ./.github/actions/restore-cache
757+
- name: Restore build artifacts
758+
uses: actions/download-artifact@v8
739759
with:
740-
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
760+
name: build-output
741761

742762
- name: Restore build bundle artifacts
743763
uses: actions/download-artifact@v8
744764
with:
745765
name: build-bundle-output
746766
path: ${{ env.BUNDLE_ARTIFACT_DOWNLOAD_PATH }}
747767

748-
- name: Install Playwright
768+
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
769+
- name: Install Playwright browsers
770+
id: install-playwright-browsers
771+
background: true
772+
uses: ./.github/actions/install-playwright
773+
with:
774+
cwd: dev-packages/browser-integration-tests
775+
part: browsers
776+
777+
- name: Install Playwright system dependencies
778+
id: install-playwright-deps
779+
background: true
749780
uses: ./.github/actions/install-playwright
750781
with:
751782
browsers: chromium
752783
cwd: dev-packages/browser-integration-tests
784+
part: system-deps
785+
786+
- name: Restore caches
787+
uses: ./.github/actions/restore-cache
788+
with:
789+
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
790+
restore-build-output: 'false'
791+
792+
- wait: [install-playwright-browsers, install-playwright-deps]
753793

754794
- name: Run Playwright Loader tests
755795
env:
@@ -1068,31 +1108,6 @@ jobs:
10681108
uses: actions/checkout@v7
10691109
with:
10701110
ref: ${{ env.HEAD_COMMIT }}
1071-
- name: Set up Node
1072-
uses: actions/setup-node@v7
1073-
with:
1074-
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json'
1075-
- name: Set up Bun
1076-
if:
1077-
matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') ||
1078-
matrix.runtime == 'bun'
1079-
uses: oven-sh/setup-bun@v2
1080-
with:
1081-
bun-version: '1.3.14'
1082-
- name: Set up AWS SAM
1083-
if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer'
1084-
uses: aws-actions/setup-sam@v3
1085-
with:
1086-
use-installer: true
1087-
token: ${{ secrets.GITHUB_TOKEN }}
1088-
- name: Set up Deno
1089-
if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno'
1090-
uses: denoland/setup-deno@v2.0.5
1091-
with:
1092-
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
1093-
- name: Install pnpm
1094-
uses: ./.github/actions/install-pnpm
1095-
10961111
- name: Restore tarball artifacts
10971112
uses: actions/download-artifact@v8
10981113
with:
@@ -1119,15 +1134,49 @@ jobs:
11191134
with:
11201135
name: build-output
11211136

1122-
# Installs Playwright while the app builds.
1137+
# Installs Playwright while the job sets up and the app builds.
11231138
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1124-
- name: Install Playwright
1125-
id: install-playwright
1139+
- name: Install Playwright browsers
1140+
id: install-playwright-browsers
1141+
background: true
1142+
uses: ./.github/actions/install-playwright
1143+
with:
1144+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1145+
part: browsers
1146+
1147+
- name: Install Playwright system dependencies
1148+
id: install-playwright-deps
11261149
background: true
11271150
uses: ./.github/actions/install-playwright
11281151
with:
11291152
browsers: chromium
11301153
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1154+
part: system-deps
1155+
1156+
- name: Install pnpm
1157+
uses: ./.github/actions/install-pnpm
1158+
- name: Set up Node
1159+
uses: actions/setup-node@v7
1160+
with:
1161+
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json'
1162+
- name: Set up Bun
1163+
if:
1164+
matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') ||
1165+
matrix.runtime == 'bun'
1166+
uses: oven-sh/setup-bun@v2
1167+
with:
1168+
bun-version: '1.3.14'
1169+
- name: Set up AWS SAM
1170+
if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer'
1171+
uses: aws-actions/setup-sam@v3
1172+
with:
1173+
use-installer: true
1174+
token: ${{ secrets.GITHUB_TOKEN }}
1175+
- name: Set up Deno
1176+
if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno'
1177+
uses: denoland/setup-deno@v2.0.5
1178+
with:
1179+
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
11311180

11321181
- name: Prepare e2e tests
11331182
run: yarn test:prepare
@@ -1154,7 +1203,7 @@ jobs:
11541203
env:
11551204
SENTRY_E2E_WORKSPACE_ROOT: ${{ github.workspace }}
11561205

1157-
- wait: [install-playwright]
1206+
- wait: [install-playwright-browsers, install-playwright-deps]
11581207

11591208
- name: Run E2E test
11601209
working-directory: ${{ runner.temp }}/test-application
@@ -1213,25 +1262,6 @@ jobs:
12131262
uses: actions/checkout@v7
12141263
with:
12151264
ref: ${{ env.HEAD_COMMIT }}
1216-
- name: Set up Node
1217-
uses: actions/setup-node@v7
1218-
with:
1219-
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json'
1220-
- name: Set up Bun
1221-
if:
1222-
matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') ||
1223-
matrix.runtime == 'bun'
1224-
uses: oven-sh/setup-bun@v2
1225-
with:
1226-
bun-version: '1.3.14'
1227-
- name: Set up Deno
1228-
if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno'
1229-
uses: denoland/setup-deno@v2.0.5
1230-
with:
1231-
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
1232-
- name: Install pnpm
1233-
uses: ./.github/actions/install-pnpm
1234-
12351265
- name: Restore tarball artifacts
12361266
uses: actions/download-artifact@v8
12371267
with:
@@ -1244,15 +1274,43 @@ jobs:
12441274
name: build-test-utils-tarball-output
12451275
path: dev-packages/test-utils
12461276

1247-
# Installs Playwright while the app builds.
1277+
# Installs Playwright while the job sets up and the app builds.
12481278
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1249-
- name: Install Playwright
1250-
id: install-playwright
1279+
- name: Install Playwright browsers
1280+
id: install-playwright-browsers
1281+
background: true
1282+
uses: ./.github/actions/install-playwright
1283+
with:
1284+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1285+
part: browsers
1286+
1287+
- name: Install Playwright system dependencies
1288+
id: install-playwright-deps
12511289
background: true
12521290
uses: ./.github/actions/install-playwright
12531291
with:
12541292
browsers: chromium
12551293
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1294+
part: system-deps
1295+
1296+
- name: Install pnpm
1297+
uses: ./.github/actions/install-pnpm
1298+
- name: Set up Node
1299+
uses: actions/setup-node@v7
1300+
with:
1301+
node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json'
1302+
- name: Set up Bun
1303+
if:
1304+
matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') ||
1305+
matrix.runtime == 'bun'
1306+
uses: oven-sh/setup-bun@v2
1307+
with:
1308+
bun-version: '1.3.14'
1309+
- name: Set up Deno
1310+
if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno'
1311+
uses: denoland/setup-deno@v2.0.5
1312+
with:
1313+
deno-version: ${{ matrix.deno-version || 'v2.8.3' }}
12561314

12571315
- name: Prepare E2E tests
12581316
run: yarn test:prepare
@@ -1277,7 +1335,7 @@ jobs:
12771335
timeout-minutes: 7
12781336
run: ${{ matrix.build-command || 'pnpm test:build' }}
12791337

1280-
- wait: [install-playwright]
1338+
- wait: [install-playwright-browsers, install-playwright-deps]
12811339

12821340
- name: Run E2E test
12831341
working-directory: ${{ runner.temp }}/test-application

0 commit comments

Comments
 (0)