diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 49177e339..20838cafa 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -46,14 +46,12 @@ jobs: id: playwright-cache with: path: ~/.cache/ms-playwright - key: playwright-${{ runner.os }}-chromium-headless-shell-1.59.0 + key: playwright-${{ runner.os }}-chromium-headless-shell-1.59.0-${{ matrix.ci_node_index }} - - name: Install Playwright Chromium Headless Shell (cache miss) - if: steps.playwright-cache.outputs.cache-hit != 'true' + - name: Install Playwright Chromium Headless Shell run: npx --yes playwright@1.59.0 install chromium-headless-shell - - name: Install Playwright system deps (cache hit) - if: steps.playwright-cache.outputs.cache-hit == 'true' + - name: Install Playwright system dependencies run: npx --yes playwright@1.59.0 install-deps chromium-headless-shell - name: Setup test databases diff --git a/Gemfile.lock b/Gemfile.lock index 80ae66dff..ffb55cca0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -160,7 +160,7 @@ GEM bigdecimal rexml crass (1.0.6) - css_parser (1.14.0) + css_parser (1.22.0) addressable csv (3.3.5) database_cleaner (2.1.0) diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index a18952825..d63699871 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -6,10 +6,25 @@ # See: https://playwright.dev/docs/browsers#chromium-headless-shell Capybara.register_driver :playwright do |app| + # Use chromium-headless-shell if available (CI), fallback to regular chromium + # Try multiple patterns to find the headless shell executable on different platforms + cache_dir = File.expand_path('~/.cache/ms-playwright') + patterns = [ + 'chromium_headless_shell-*/**/headless_shell', # Linux + 'chromium_headless_shell-*/**/chrome-headless-shell', # Mac + ] + + headless_shell = patterns.map do |pattern| + Dir.glob(File.join(cache_dir, pattern)).max + end.compact.first + + executable_path = headless_shell if headless_shell && File.executable?(headless_shell) + Capybara::Playwright::Driver.new( app, headless: ENV.fetch('PLAYWRIGHT_HEADLESS', 'true') !~ /^(false|no|0)$/i, - browser_type: ENV.fetch('PLAYWRIGHT_BROWSER', 'chromium').to_sym + browser_type: ENV.fetch('PLAYWRIGHT_BROWSER', 'chromium').to_sym, + executablePath: executable_path ) end