Files
sanderling/.github/actions/headless-chrome/action.yml
T
2026-08-16 17:16:47 +05:30

31 lines
1.3 KiB
YAML

name: headless chrome
description: Install Chrome and prove it starts headless before a driver depends on it.
runs:
using: composite
steps:
# stable is setup-chrome v2's own default, spelled out so a new release of
# the action cannot move the browser these jobs drive. The alternative it
# offers is Chrome for Testing latest, which tracks ahead of the channel
# users run.
- uses: browser-actions/setup-chrome@48ad923757ca74d66703209fe939badbdf80f2f4 # v2.2.0
with:
chrome-version: stable
# Ubuntu 24.04 (current ubuntu-latest) restricts unprivileged user
# namespaces via AppArmor, which stops headless Chrome from starting even
# with --no-sandbox: the process launches but never opens its DevTools
# socket. Re-enable them so the driver's Chrome can come up.
- name: Allow Chrome under unprivileged user namespaces
shell: bash
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
# Fail here with Chrome's own stderr if the browser can't launch, instead
# of letting the driver report an opaque DevTools timeout downstream.
- name: Verify headless Chrome starts
shell: bash
run: |
chrome --version
chrome --headless --no-sandbox --disable-gpu --disable-dev-shm-usage \
--dump-dom 'data:text/html,<title>ok</title>'