Skip to content

Commit ffdf45a

Browse files
committed
fix(ci): use chromium-headless-shell with isolated caches
Fix race condition in parallel test jobs by adding matrix index to cache key. Use chromium-headless-shell by passing executable_path to Playwright driver. Changes: - Add ${{ matrix.ci_node_index }} to cache key for isolated caches per job - Install chromium-headless-shell instead of full chromium - Detect and use headless_shell executable in capybara driver config
1 parent 73ee17c commit ffdf45a

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/ruby.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ jobs:
4646
id: playwright-cache
4747
with:
4848
path: ~/.cache/ms-playwright
49-
key: playwright-${{ runner.os }}-chromium-headless-shell-1.59.0
49+
key: playwright-${{ runner.os }}-chromium-headless-shell-1.59.0-${{ matrix.ci_node_index }}
5050

51-
- name: Install Playwright Chromium Headless Shell (cache miss)
52-
if: steps.playwright-cache.outputs.cache-hit != 'true'
51+
- name: Install Playwright Chromium Headless Shell
5352
run: npx --yes playwright@1.59.0 install chromium-headless-shell
5453

55-
- name: Install Playwright system deps (cache hit)
56-
if: steps.playwright-cache.outputs.cache-hit == 'true'
54+
- name: Install Playwright system dependencies
5755
run: npx --yes playwright@1.59.0 install-deps chromium-headless-shell
5856

5957
- name: Setup test databases

spec/support/capybara.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
# See: https://playwright.dev/docs/browsers#chromium-headless-shell
77

88
Capybara.register_driver :playwright do |app|
9+
# Use chromium-headless-shell if available (CI), fallback to regular chromium
10+
headless_shell = Dir.glob(File.expand_path('~/.cache/ms-playwright/chromium_headless_shell-*/chrome-linux/headless_shell')).max
11+
executable_path = headless_shell if headless_shell && File.executable?(headless_shell)
12+
913
Capybara::Playwright::Driver.new(
1014
app,
1115
headless: ENV.fetch('PLAYWRIGHT_HEADLESS', 'true') !~ /^(false|no|0)$/i,
12-
browser_type: ENV.fetch('PLAYWRIGHT_BROWSER', 'chromium').to_sym
16+
browser_type: ENV.fetch('PLAYWRIGHT_BROWSER', 'chromium').to_sym,
17+
executablePath: executable_path
1318
)
1419
end
1520

0 commit comments

Comments
 (0)