Skip to content

Commit 3db934a

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 e179217 commit 3db934a

3 files changed

Lines changed: 148 additions & 57 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: 119 additions & 49 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:
@@ -1061,6 +1101,43 @@ jobs:
10611101
uses: actions/checkout@v7
10621102
with:
10631103
ref: ${{ env.HEAD_COMMIT }}
1104+
- name: Restore build artifacts
1105+
uses: actions/download-artifact@v8
1106+
with:
1107+
name: build-output
1108+
1109+
- name: Restore tarball artifacts
1110+
uses: actions/download-artifact@v8
1111+
with:
1112+
name: build-tarball-output
1113+
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
1114+
1115+
- name: Restore build layer artifacts
1116+
uses: actions/download-artifact@v8
1117+
if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer'
1118+
with:
1119+
name: build-layer-output
1120+
path: ${{ env.BUILD_LAYER_PATH }}
1121+
1122+
# Installs Playwright while the job sets up and the app builds.
1123+
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1124+
- name: Install Playwright browsers
1125+
id: install-playwright-browsers
1126+
background: true
1127+
uses: ./.github/actions/install-playwright
1128+
with:
1129+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1130+
part: browsers
1131+
1132+
- name: Install Playwright system dependencies
1133+
id: install-playwright-deps
1134+
background: true
1135+
uses: ./.github/actions/install-playwright
1136+
with:
1137+
browsers: chromium
1138+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1139+
part: system-deps
1140+
10641141
- name: Install pnpm
10651142
uses: ./.github/actions/install-pnpm
10661143
with:
@@ -1091,29 +1168,7 @@ jobs:
10911168
uses: ./.github/actions/restore-cache
10921169
with:
10931170
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
1094-
1095-
- name: Restore tarball artifacts
1096-
uses: actions/download-artifact@v8
1097-
with:
1098-
name: build-tarball-output
1099-
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
1100-
1101-
- name: Restore build layer artifacts
1102-
uses: actions/download-artifact@v8
1103-
if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer'
1104-
with:
1105-
name: build-layer-output
1106-
path: ${{ env.BUILD_LAYER_PATH }}
1107-
1108-
# Installs Playwright while the app builds.
1109-
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1110-
- name: Install Playwright
1111-
id: install-playwright
1112-
background: true
1113-
uses: ./.github/actions/install-playwright
1114-
with:
1115-
browsers: chromium
1116-
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1171+
restore-build-output: 'false'
11171172

11181173
- name: Prepare e2e tests
11191174
run: yarn test:prepare
@@ -1140,7 +1195,7 @@ jobs:
11401195
env:
11411196
SENTRY_E2E_WORKSPACE_ROOT: ${{ github.workspace }}
11421197

1143-
- wait: [install-playwright]
1198+
- wait: [install-playwright-browsers, install-playwright-deps]
11441199

11451200
- name: Run E2E test
11461201
working-directory: ${{ runner.temp }}/test-application
@@ -1214,6 +1269,36 @@ jobs:
12141269
uses: actions/checkout@v7
12151270
with:
12161271
ref: ${{ env.HEAD_COMMIT }}
1272+
- name: Restore build artifacts
1273+
uses: actions/download-artifact@v8
1274+
with:
1275+
name: build-output
1276+
1277+
- name: Restore tarball artifacts
1278+
uses: actions/download-artifact@v8
1279+
with:
1280+
name: build-tarball-output
1281+
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
1282+
1283+
# Installs Playwright while the job sets up and the app builds.
1284+
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1285+
- name: Install Playwright browsers
1286+
id: install-playwright-browsers
1287+
background: true
1288+
uses: ./.github/actions/install-playwright
1289+
with:
1290+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1291+
part: browsers
1292+
1293+
- name: Install Playwright system dependencies
1294+
id: install-playwright-deps
1295+
background: true
1296+
uses: ./.github/actions/install-playwright
1297+
with:
1298+
browsers: chromium
1299+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1300+
part: system-deps
1301+
12171302
- name: Install pnpm
12181303
uses: ./.github/actions/install-pnpm
12191304
with:
@@ -1238,22 +1323,7 @@ jobs:
12381323
uses: ./.github/actions/restore-cache
12391324
with:
12401325
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
1241-
1242-
- name: Restore tarball artifacts
1243-
uses: actions/download-artifact@v8
1244-
with:
1245-
name: build-tarball-output
1246-
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
1247-
1248-
# Installs Playwright while the app builds.
1249-
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1250-
- name: Install Playwright
1251-
id: install-playwright
1252-
background: true
1253-
uses: ./.github/actions/install-playwright
1254-
with:
1255-
browsers: chromium
1256-
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1326+
restore-build-output: 'false'
12571327

12581328
- name: Prepare E2E tests
12591329
run: yarn test:prepare
@@ -1278,7 +1348,7 @@ jobs:
12781348
timeout-minutes: 7
12791349
run: ${{ matrix.build-command || 'pnpm test:build' }}
12801350

1281-
- wait: [install-playwright]
1351+
- wait: [install-playwright-browsers, install-playwright-deps]
12821352

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

0 commit comments

Comments
 (0)