Skip to content

Commit d873fce

Browse files
mydeaclaude
andcommitted
chore(ci): Use custom GHCR Playwright image for all Playwright jobs
Build a custom Docker image extending the official Playwright image with yarn pre-installed, push it to GHCR, and use it across all CI jobs that need Playwright browsers. - Add `.github/docker/playwright.Dockerfile` with yarn@1.22.22 - Add build workflow that pushes to GHCR on Dockerfile or Playwright version changes - All Playwright jobs (browser tests, loader tests, Remix, E2E, canary, flaky-test-detector) now use the GHCR container image - No more `npx playwright install` or browser caching logic anywhere When bumping @playwright/test, also update the PLAYWRIGHT_IMAGE env var in build.yml, canary.yml, and flaky-test-detector.yml. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d5055f3 commit d873fce

File tree

5 files changed

+78
-24
lines changed

5 files changed

+78
-24
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ARG PLAYWRIGHT_VERSION=1.56.1
2+
FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-noble
3+
4+
# Install yarn (v1) for the monorepo
5+
RUN npm install -g yarn@1.22.22
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build Playwright Docker Image
2+
on:
3+
push:
4+
branches: [develop]
5+
paths:
6+
- '.github/docker/playwright.Dockerfile'
7+
- 'dev-packages/browser-integration-tests/package.json'
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-image:
12+
runs-on: ubuntu-24.04
13+
permissions:
14+
packages: write
15+
steps:
16+
- uses: actions/checkout@v6
17+
18+
- name: Get Playwright version
19+
id: playwright
20+
run: echo "version=$(node -p "require('./dev-packages/browser-integration-tests/package.json').devDependencies['@playwright/test'].replace('~', '')")" >> $GITHUB_OUTPUT
21+
22+
- name: Log in to GHCR
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Build and push
30+
uses: docker/build-push-action@v6
31+
with:
32+
file: .github/docker/playwright.Dockerfile
33+
push: true
34+
build-args: |
35+
PLAYWRIGHT_VERSION=${{ steps.playwright.outputs.version }}
36+
tags: |
37+
ghcr.io/${{ github.repository }}/playwright:v${{ steps.playwright.outputs.version }}

.github/workflows/build.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ concurrency:
2727

2828
env:
2929
HEAD_COMMIT: ${{ github.event.inputs.commit || github.sha }}
30+
PLAYWRIGHT_IMAGE: ghcr.io/getsentry/sentry-javascript/playwright:v1.56.1
3031

3132
# WARNING: this disables cross os caching as ~ and
3233
# github.workspace evaluate to differents paths
@@ -479,7 +480,10 @@ jobs:
479480
if: needs.job_build.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
480481
runs-on: ubuntu-24.04-large-js
481482
container:
482-
image: mcr.microsoft.com/playwright:v1.56.1-noble
483+
image: ${{ env.PLAYWRIGHT_IMAGE }}
484+
credentials:
485+
username: ${{ github.actor }}
486+
password: ${{ secrets.GITHUB_TOKEN }}
483487
timeout-minutes: 25
484488
strategy:
485489
fail-fast: false
@@ -537,8 +541,6 @@ jobs:
537541
uses: actions/setup-node@v6
538542
with:
539543
node-version-file: 'package.json'
540-
- name: Install yarn
541-
run: npm install -g yarn@1.22.22
542544
- name: Restore caches
543545
uses: ./.github/actions/restore-cache
544546
with:
@@ -581,7 +583,10 @@ jobs:
581583
if: needs.job_build.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
582584
runs-on: ubuntu-24.04
583585
container:
584-
image: mcr.microsoft.com/playwright:v1.56.1-noble
586+
image: ${{ env.PLAYWRIGHT_IMAGE }}
587+
credentials:
588+
username: ${{ github.actor }}
589+
password: ${{ secrets.GITHUB_TOKEN }}
585590
timeout-minutes: 15
586591
strategy:
587592
fail-fast: false
@@ -604,8 +609,6 @@ jobs:
604609
uses: actions/setup-node@v6
605610
with:
606611
node-version-file: 'package.json'
607-
- name: Install yarn
608-
run: npm install -g yarn@1.22.22
609612
- name: Restore caches
610613
uses: ./.github/actions/restore-cache
611614
with:
@@ -772,6 +775,11 @@ jobs:
772775
needs: [job_get_metadata, job_build]
773776
if: needs.job_build.outputs.changed_remix == 'true' || github.event_name != 'pull_request'
774777
runs-on: ubuntu-24.04
778+
container:
779+
image: ${{ env.PLAYWRIGHT_IMAGE }}
780+
credentials:
781+
username: ${{ github.actor }}
782+
password: ${{ secrets.GITHUB_TOKEN }}
775783
timeout-minutes: 15
776784
strategy:
777785
fail-fast: false
@@ -791,9 +799,6 @@ jobs:
791799
with:
792800
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
793801

794-
- name: Install Playwright
795-
run: npx playwright install --with-deps chromium
796-
797802
- name: Run integration tests
798803
env:
799804
NODE_VERSION: ${{ matrix.node }}
@@ -871,6 +876,11 @@ jobs:
871876
always() && needs.job_e2e_prepare.result == 'success' && needs.job_e2e_prepare.outputs.matrix != '{"include":[]}'
872877
needs: [job_get_metadata, job_build, job_e2e_prepare]
873878
runs-on: ubuntu-24.04
879+
container:
880+
image: ${{ env.PLAYWRIGHT_IMAGE }}
881+
credentials:
882+
username: ${{ github.actor }}
883+
password: ${{ secrets.GITHUB_TOKEN }}
874884
timeout-minutes: 15
875885
env:
876886
# We just use a dummy DSN here, only send to the tunnel anyhow
@@ -952,10 +962,6 @@ jobs:
952962
env:
953963
SENTRY_E2E_WORKSPACE_ROOT: ${{ github.workspace }}
954964

955-
- name: Install Playwright
956-
run: npx playwright install --with-deps chromium
957-
working-directory: ${{ runner.temp }}/test-application
958-
959965
- name: Run E2E test
960966
working-directory: ${{ runner.temp }}/test-application
961967
timeout-minutes: 10
@@ -999,6 +1005,11 @@ jobs:
9991005
github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]'
10001006
needs: [job_get_metadata, job_build, job_e2e_prepare]
10011007
runs-on: ubuntu-24.04
1008+
container:
1009+
image: ${{ env.PLAYWRIGHT_IMAGE }}
1010+
credentials:
1011+
username: ${{ github.actor }}
1012+
password: ${{ secrets.GITHUB_TOKEN }}
10021013
timeout-minutes: 15
10031014
env:
10041015
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
@@ -1065,10 +1076,6 @@ jobs:
10651076
timeout-minutes: 7
10661077
run: ${{ matrix.build-command || 'pnpm test:build' }}
10671078

1068-
- name: Install Playwright
1069-
run: npx playwright install --with-deps chromium
1070-
working-directory: ${{ runner.temp }}/test-application
1071-
10721079
- name: Run E2E test
10731080
working-directory: ${{ runner.temp }}/test-application
10741081
timeout-minutes: 10

.github/workflows/canary.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111

1212
env:
1313
HEAD_COMMIT: ${{ github.event.inputs.commit || github.sha }}
14+
PLAYWRIGHT_IMAGE: ghcr.io/getsentry/sentry-javascript/playwright:v1.56.1
1415

1516
CACHED_BUILD_PATHS: |
1617
${{ github.workspace }}/packages/*/*.tgz
@@ -55,6 +56,11 @@ jobs:
5556
name: E2E ${{ matrix.label }} Test
5657
needs: [job_e2e_prepare]
5758
runs-on: ubuntu-24.04
59+
container:
60+
image: ${{ env.PLAYWRIGHT_IMAGE }}
61+
credentials:
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
5864
timeout-minutes: 20
5965
env:
6066
# We just use a dummy DSN here, only send to the tunnel anyhow
@@ -164,10 +170,6 @@ jobs:
164170
timeout-minutes: 7
165171
run: yarn ${{ matrix.build-command }}
166172

167-
- name: Install Playwright
168-
run: npx playwright install --with-deps chromium
169-
working-directory: ${{ runner.temp }}/test-application
170-
171173
- name: Run E2E test
172174
working-directory: ${{ runner.temp }}/test-application
173175
timeout-minutes: 15

.github/workflows/flaky-test-detector.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
env:
1111
HEAD_COMMIT: ${{ github.event.inputs.commit || github.sha }}
12+
PLAYWRIGHT_IMAGE: ghcr.io/getsentry/sentry-javascript/playwright:v1.56.1
1213

1314
NX_CACHE_RESTORE_KEYS: |
1415
nx-Linux-${{ github.ref }}-${{ github.event.inputs.commit || github.sha }}
@@ -24,6 +25,11 @@ concurrency:
2425
jobs:
2526
flaky-detector:
2627
runs-on: ubuntu-24.04
28+
container:
29+
image: ${{ env.PLAYWRIGHT_IMAGE }}
30+
credentials:
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
2733
timeout-minutes: 60
2834
name: 'Check tests for flakiness'
2935
# Also skip if PR is from master -> develop
@@ -49,9 +55,6 @@ jobs:
4955
- name: Build packages
5056
run: yarn build
5157

52-
- name: Install Playwright
53-
run: npx playwright install --with-deps chromium
54-
5558
- name: Determine changed tests
5659
uses: dorny/paths-filter@v4.0.1
5760
id: changed

0 commit comments

Comments
 (0)