Skip to content

Commit f1ce064

Browse files
authored
🤖 ci: optimize Playwright installation with caching (#740)
## Summary Optimizes Playwright installation in CI by caching browser binaries and installing only chromium. ## Changes ### New `.github/actions/setup-playwright` composite action - Caches `~/.cache/ms-playwright` keyed by Playwright version from bun.lock - On cache hit: skips browser download, only runs `install-deps` - Installs only **chromium** (sufficient for E2E and Storybook, ~3x smaller than all browsers) ### Updated CI jobs - `storybook-test`: uses new composite action (was: `playwright install --with-deps`) - `e2e-test`: uses new composite action (replaces 3 separate steps) ## Expected Impact | Scenario | Before | After | |----------|--------|-------| | Cache hit | Download all browsers | Skip download (save ~90s) | | Cache miss | Download all browsers | Download chromium only | The cache hit path is the common case after the first run per Playwright version. --- _Generated with `mux`_
1 parent 05ce4b6 commit f1ce064

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Setup Playwright"
2+
description: "Install Playwright browsers and dependencies with caching"
3+
inputs:
4+
browsers:
5+
description: "Space-separated list of browsers to install (e.g., 'chromium', 'chromium webkit')"
6+
required: false
7+
default: "chromium"
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Get Playwright version
12+
id: playwright-version
13+
shell: bash
14+
run: |
15+
# Extract Playwright version from bun.lock
16+
VERSION=$(grep -A1 '"playwright":' bun.lock | grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+' | head -1)
17+
echo "version=$VERSION" >> $GITHUB_OUTPUT
18+
echo "Playwright version: $VERSION"
19+
20+
- name: Cache Playwright browsers
21+
id: cache-playwright
22+
uses: actions/cache@v4
23+
with:
24+
path: ~/.cache/ms-playwright
25+
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-${{ inputs.browsers }}
26+
restore-keys: |
27+
${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-
28+
29+
- name: Install Playwright browsers
30+
if: steps.cache-playwright.outputs.cache-hit != 'true'
31+
shell: bash
32+
run: bun x playwright install ${{ inputs.browsers }}
33+
34+
- name: Install Playwright system dependencies
35+
shell: bash
36+
run: bun x playwright install-deps ${{ inputs.browsers }}

.github/workflows/ci.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ jobs:
134134

135135
- uses: ./.github/actions/setup-mux
136136

137-
- name: Install Playwright browsers
138-
run: bun x playwright install --with-deps
137+
- uses: ./.github/actions/setup-playwright
139138

140139
- name: Build Storybook
141140
run: make storybook-build
@@ -160,16 +159,12 @@ jobs:
160159

161160
- uses: ./.github/actions/setup-mux
162161

163-
- name: Install system dependencies
162+
- name: Install xvfb
164163
run: |
165164
sudo apt-get update
166165
sudo apt-get install -y xvfb
167166
168-
- name: Install Playwright runtime dependencies
169-
run: bun x playwright install-deps
170-
171-
- name: Install Playwright browsers
172-
run: bun x playwright install --with-deps
167+
- uses: ./.github/actions/setup-playwright
173168

174169
- name: Run e2e tests
175170
run: xvfb-run -a make test-e2e

0 commit comments

Comments
 (0)