Skip to content

Commit d341175

Browse files
mydeaclaude
andcommitted
chore(ci): Run Playwright image build on PRs, verify version consistency
- Trigger the build workflow on PRs that change the Dockerfile, Playwright version, or any e2e test application package.json - Add a version consistency check that verifies all packages and e2e test applications use the same @playwright/test version as the canonical source (dev-packages/browser-integration-tests) - On PRs, the image is built (to verify the Dockerfile) but not pushed - On push to develop and workflow_dispatch, the image is built and pushed Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d873fce commit d341175

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

.github/workflows/build-playwright-docker-image.yml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,70 @@ on:
55
paths:
66
- '.github/docker/playwright.Dockerfile'
77
- 'dev-packages/browser-integration-tests/package.json'
8+
pull_request:
9+
paths:
10+
- '.github/docker/playwright.Dockerfile'
11+
- 'dev-packages/browser-integration-tests/package.json'
12+
- 'dev-packages/e2e-tests/test-applications/*/package.json'
13+
- 'dev-packages/test-utils/package.json'
814
workflow_dispatch:
915

1016
jobs:
17+
verify-playwright-versions:
18+
name: Verify Playwright version consistency
19+
runs-on: ubuntu-24.04
20+
steps:
21+
- uses: actions/checkout@v6
22+
23+
- name: Check all @playwright/test versions match
24+
run: |
25+
# Get the canonical version from browser-integration-tests
26+
CANONICAL=$(node -p "require('./dev-packages/browser-integration-tests/package.json').devDependencies['@playwright/test']")
27+
echo "Canonical @playwright/test version: $CANONICAL"
28+
29+
MISMATCHES=0
30+
31+
# Check test-utils
32+
for pkg in dev-packages/test-utils/package.json; do
33+
VERSION=$(node -p "
34+
const pkg = require('./$pkg');
35+
(pkg.dependencies || {})['@playwright/test'] ||
36+
(pkg.devDependencies || {})['@playwright/test'] ||
37+
(pkg.peerDependencies || {})['@playwright/test'] ||
38+
'not found'
39+
")
40+
if [ "$VERSION" != "not found" ] && [ "$VERSION" != "$CANONICAL" ]; then
41+
echo "::error file=$pkg::@playwright/test version mismatch: $VERSION (expected $CANONICAL)"
42+
MISMATCHES=$((MISMATCHES + 1))
43+
fi
44+
done
45+
46+
# Check all e2e test applications
47+
for pkg in dev-packages/e2e-tests/test-applications/*/package.json; do
48+
VERSION=$(node -p "
49+
const pkg = require('./$pkg');
50+
(pkg.dependencies || {})['@playwright/test'] ||
51+
(pkg.devDependencies || {})['@playwright/test'] ||
52+
'not found'
53+
")
54+
if [ "$VERSION" != "not found" ] && [ "$VERSION" != "$CANONICAL" ]; then
55+
echo "::error file=$pkg::@playwright/test version mismatch: $VERSION (expected $CANONICAL)"
56+
MISMATCHES=$((MISMATCHES + 1))
57+
fi
58+
done
59+
60+
if [ "$MISMATCHES" -gt 0 ]; then
61+
echo ""
62+
echo "Found $MISMATCHES package(s) with mismatched @playwright/test versions."
63+
echo "All packages must use the same version as dev-packages/browser-integration-tests ($CANONICAL)."
64+
exit 1
65+
fi
66+
67+
echo "All @playwright/test versions are consistent ($CANONICAL)"
68+
1169
build-image:
70+
name: Build Playwright Docker Image
71+
needs: [verify-playwright-versions]
1272
runs-on: ubuntu-24.04
1373
permissions:
1474
packages: write
@@ -30,7 +90,7 @@ jobs:
3090
uses: docker/build-push-action@v6
3191
with:
3292
file: .github/docker/playwright.Dockerfile
33-
push: true
93+
push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
3494
build-args: |
3595
PLAYWRIGHT_VERSION=${{ steps.playwright.outputs.version }}
3696
tags: |

0 commit comments

Comments
 (0)