Skip to content

Commit fbff338

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 959a597 commit fbff338

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
@@ -669,22 +669,42 @@ jobs:
669669
uses: actions/setup-node@v7
670670
with:
671671
node-version-file: 'package.json'
672-
- name: Restore caches
673-
uses: ./.github/actions/restore-cache
672+
- name: Restore build artifacts
673+
uses: actions/download-artifact@v8
674674
with:
675-
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
675+
name: build-output
676676

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

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

689709
- name: Run Playwright tests
690710
env:
@@ -732,22 +752,42 @@ jobs:
732752
uses: actions/setup-node@v7
733753
with:
734754
node-version-file: 'package.json'
735-
- name: Restore caches
736-
uses: ./.github/actions/restore-cache
755+
- name: Restore build artifacts
756+
uses: actions/download-artifact@v8
737757
with:
738-
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
758+
name: build-output
739759

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

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

752792
- name: Run Playwright Loader tests
753793
env:
@@ -1059,6 +1099,43 @@ jobs:
10591099
uses: actions/checkout@v7
10601100
with:
10611101
ref: ${{ env.HEAD_COMMIT }}
1102+
- name: Restore build artifacts
1103+
uses: actions/download-artifact@v8
1104+
with:
1105+
name: build-output
1106+
1107+
- name: Restore tarball artifacts
1108+
uses: actions/download-artifact@v8
1109+
with:
1110+
name: build-tarball-output
1111+
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
1112+
1113+
- name: Restore build layer artifacts
1114+
uses: actions/download-artifact@v8
1115+
if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer'
1116+
with:
1117+
name: build-layer-output
1118+
path: ${{ env.BUILD_LAYER_PATH }}
1119+
1120+
# Installs Playwright while the job sets up and the app builds.
1121+
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1122+
- name: Install Playwright browsers
1123+
id: install-playwright-browsers
1124+
background: true
1125+
uses: ./.github/actions/install-playwright
1126+
with:
1127+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1128+
part: browsers
1129+
1130+
- name: Install Playwright system dependencies
1131+
id: install-playwright-deps
1132+
background: true
1133+
uses: ./.github/actions/install-playwright
1134+
with:
1135+
browsers: chromium
1136+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1137+
part: system-deps
1138+
10621139
- name: Install pnpm
10631140
uses: ./.github/actions/install-pnpm
10641141
with:
@@ -1089,29 +1166,7 @@ jobs:
10891166
uses: ./.github/actions/restore-cache
10901167
with:
10911168
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
1092-
1093-
- name: Restore tarball artifacts
1094-
uses: actions/download-artifact@v8
1095-
with:
1096-
name: build-tarball-output
1097-
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
1098-
1099-
- name: Restore build layer artifacts
1100-
uses: actions/download-artifact@v8
1101-
if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer'
1102-
with:
1103-
name: build-layer-output
1104-
path: ${{ env.BUILD_LAYER_PATH }}
1105-
1106-
# Installs Playwright while the app builds.
1107-
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1108-
- name: Install Playwright
1109-
id: install-playwright
1110-
background: true
1111-
uses: ./.github/actions/install-playwright
1112-
with:
1113-
browsers: chromium
1114-
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1169+
restore-build-output: 'false'
11151170

11161171
- name: Prepare e2e tests
11171172
run: yarn test:prepare
@@ -1138,7 +1193,7 @@ jobs:
11381193
env:
11391194
SENTRY_E2E_WORKSPACE_ROOT: ${{ github.workspace }}
11401195

1141-
- wait: [install-playwright]
1196+
- wait: [install-playwright-browsers, install-playwright-deps]
11421197

11431198
- name: Run E2E test
11441199
working-directory: ${{ runner.temp }}/test-application
@@ -1212,6 +1267,36 @@ jobs:
12121267
uses: actions/checkout@v7
12131268
with:
12141269
ref: ${{ env.HEAD_COMMIT }}
1270+
- name: Restore build artifacts
1271+
uses: actions/download-artifact@v8
1272+
with:
1273+
name: build-output
1274+
1275+
- name: Restore tarball artifacts
1276+
uses: actions/download-artifact@v8
1277+
with:
1278+
name: build-tarball-output
1279+
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
1280+
1281+
# Installs Playwright while the job sets up and the app builds.
1282+
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1283+
- name: Install Playwright browsers
1284+
id: install-playwright-browsers
1285+
background: true
1286+
uses: ./.github/actions/install-playwright
1287+
with:
1288+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1289+
part: browsers
1290+
1291+
- name: Install Playwright system dependencies
1292+
id: install-playwright-deps
1293+
background: true
1294+
uses: ./.github/actions/install-playwright
1295+
with:
1296+
browsers: chromium
1297+
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1298+
part: system-deps
1299+
12151300
- name: Install pnpm
12161301
uses: ./.github/actions/install-pnpm
12171302
with:
@@ -1236,22 +1321,7 @@ jobs:
12361321
uses: ./.github/actions/restore-cache
12371322
with:
12381323
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
1239-
1240-
- name: Restore tarball artifacts
1241-
uses: actions/download-artifact@v8
1242-
with:
1243-
name: build-tarball-output
1244-
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}
1245-
1246-
# Installs Playwright while the app builds.
1247-
# Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file.
1248-
- name: Install Playwright
1249-
id: install-playwright
1250-
background: true
1251-
uses: ./.github/actions/install-playwright
1252-
with:
1253-
browsers: chromium
1254-
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}
1324+
restore-build-output: 'false'
12551325

12561326
- name: Prepare E2E tests
12571327
run: yarn test:prepare
@@ -1276,7 +1346,7 @@ jobs:
12761346
timeout-minutes: 7
12771347
run: ${{ matrix.build-command || 'pnpm test:build' }}
12781348

1279-
- wait: [install-playwright]
1349+
- wait: [install-playwright-browsers, install-playwright-deps]
12801350

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

0 commit comments

Comments
 (0)