Skip to content

Commit c5f10d2

Browse files
mydeaclaude
andcommitted
ci: Skip Playwright install for e2e apps without @playwright/test
Move the "does this app need Playwright" decision into the install-playwright action: it resolves @playwright/test from the app and, when the package isn't there, emits an empty version and skips the browser install (and its cache steps) instead of failing on the missing require. Apps that assert via a plain node script (e.g. the node bundler apps) no longer pay for a Playwright install they don't use, with no per-app config or extra workflow step to maintain. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f49ca59 commit c5f10d2

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ inputs:
1111
runs:
1212
using: 'composite'
1313
steps:
14+
# Resolve the app's @playwright/test version. Some apps (e.g. the node bundler apps) assert via a
15+
# plain node script and don't depend on Playwright — emit an empty version instead of failing, so
16+
# the steps below skip the (wasted) browser install rather than erroring on the missing package.
1417
- name: Get Playwright version
1518
id: playwright-version
16-
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
19+
run: |
20+
version=$(node -e "let v = ''; try { v = require('@playwright/test/package.json').version; } catch {} process.stdout.write(String(v));")
21+
echo "version=$version" >> "$GITHUB_OUTPUT"
1722
shell: bash
1823
working-directory: ${{ inputs.cwd }}
1924

2025
- name: Restore cached playwright binaries
2126
uses: actions/cache/restore@v6.1.0
2227
id: playwright-cache
28+
if: steps.playwright-version.outputs.version != ''
2329
with:
2430
path: |
2531
~/.cache/ms-playwright
@@ -29,22 +35,24 @@ runs:
2935
# We always install all browsers, if uncached
3036
- name: Install Playwright dependencies (uncached)
3137
run: npx playwright install chromium webkit firefox --with-deps
32-
if: steps.playwright-cache.outputs.cache-hit != 'true'
38+
if: steps.playwright-version.outputs.version != '' && steps.playwright-cache.outputs.cache-hit != 'true'
3339
shell: bash
3440
working-directory: ${{ inputs.cwd }}
3541

3642
- name: Install Playwright system dependencies only (cached)
3743
env:
3844
PLAYWRIGHT_BROWSERS: ${{ inputs.browsers || 'chromium webkit firefox' }}
3945
run: npx playwright install-deps "$PLAYWRIGHT_BROWSERS"
40-
if: steps.playwright-cache.outputs.cache-hit == 'true'
46+
if: steps.playwright-version.outputs.version != '' && steps.playwright-cache.outputs.cache-hit == 'true'
4147
shell: bash
4248
working-directory: ${{ inputs.cwd }}
4349

4450
# Only store cache on develop branch
4551
- name: Store cached playwright binaries
4652
uses: actions/cache/save@v6.1.0
47-
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
53+
if:
54+
steps.playwright-version.outputs.version != '' && github.event_name == 'push' && github.ref ==
55+
'refs/heads/develop'
4856
with:
4957
path: |
5058
~/.cache/ms-playwright

0 commit comments

Comments
 (0)