Repository navigation
Stop Setup Playwright from hanging on apt-get - #27252
Conversation
ref https://github.com/TryGhost/Ghost/actions/runs/24159541042/job/70507436257 The Comments-UI, ActivityPub, Admin-X Settings and Signup-form jobs all relied on a custom Setup Playwright composite action that ran 'npx playwright install --with-deps' on cache miss and 'npx playwright install-deps' on cache hit. Both code paths shell out to apt-get, which has been intermittently hanging GitHub-hosted runners for the full job timeout. The recent Comments-UI run sat on Setup Playwright for ~33 minutes before being cancelled, with every other step finishing in seconds. Switch the four affected jobs to run inside the official Microsoft Playwright Docker image (mcr.microsoft.com/playwright:v1.58.2-noble), which ships browsers, OS dependencies and Node.js 22 LTS pre-installed. That removes the apt-get path entirely, so there is no Setup Playwright step left to hang on. Pin PLAYWRIGHT_VERSION as a workflow env var with a comment reminding maintainers to keep it in sync with @playwright/test in the apps and e2e package manifests, and drop the now-unused .github/actions/setup-playwright composite action.
WalkthroughThe Playwright setup composite action is updated to remove the man-db trigger refresh disabling step. The Playwright installation behavior is simplified to always run 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 26-30: The workflow documents PLAYWRIGHT_VERSION but four job
container image tags still hard-code v1.58.2; update those container image
references that use "mcr.microsoft.com/playwright:v1.58.2" to reference the env
var instead (e.g., use the PLAYWRIGHT_VERSION env via the expression syntax used
in this file) so the single PLAYWRIGHT_VERSION value becomes the source of truth
for all Playwright Docker images; ensure the jobs that set container use the
same env interpolation format as other steps so bumping PLAYWRIGHT_VERSION
updates every job.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: df4d2ed8-bd93-43a6-82e3-e57453ac1cef
📒 Files selected for processing (2)
.github/actions/setup-playwright/action.yml.github/workflows/ci.yml
💤 Files with no reviewable changes (1)
- .github/actions/setup-playwright/action.yml
Replace the hardcoded PLAYWRIGHT_VERSION env var with a dynamic job_setup output that reads @playwright/test directly out of apps/comments-ui/package.json. The four Playwright-using app test jobs now reference needs.job_setup.outputs.playwright_version when picking the container image, so the Microsoft Playwright Docker tag is always the same version Renovate just bumped @playwright/test to. This removes the maintenance burden of keeping a second source of truth in sync with Renovate, without needing a custom Renovate manager.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27252 +/- ##
=======================================
Coverage 73.45% 73.45%
=======================================
Files 1545 1545
Lines 123645 123663 +18
Branches 14956 14959 +3
=======================================
+ Hits 90822 90837 +15
- Misses 31824 31827 +3
Partials 999 999
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The container-based approach from the previous commits worked around the Setup Playwright hang, but ran into a known limitation of actions/cache: caches saved in the host job_setup are not visible to container jobs (actions/cache#1455 / #1300). The activitypub run for this PR fell through to install-deps.sh and then failed inside the Playwright image because node-gyp could not rebuild sqlite3 without Python distutils. Revert the four Playwright-using app test jobs back to ubuntu-latest and fix the underlying apt-get hang in the Setup Playwright composite action itself. The GitHub Actions ubuntu-latest runner image already ships with all of the system libraries Playwright's bundled browsers need, so there is no reason for the action to go through apt-get at all. Both code paths that called apt-get have been removed: - The cache-miss step now runs 'npx playwright install' instead of 'npx playwright install --with-deps'. - The cache-hit step that previously ran 'npx playwright install-deps' has been deleted entirely. This eliminates the ~30 minute Setup Playwright hangs without changing how the jobs run or introducing a container compatibility matrix.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/actions/setup-playwright/action.yml (1)
23-25: Add defensive error handling for dependency availability and explicit npx mode.While the
restore-cacheaction provides a fallback that runsyarn installon cache miss (viainstall-deps.sh), hardening these two lines makes failures more explicit and prevents unexpected behavior:
- Line 24 assumes
@playwright/testis resolvable; if dependency restore drifts or an edge case occurs, a silent empty version string could mask the issue.- Line 40's
npx playwright installcould attempt auto-installation if the local package isn't found;--no-installmakes resolution explicit and prevents tool installation from within the action.♻️ Suggested hardening
- name: Get Playwright version id: playwright-version shell: bash run: | - version="$(node -p "require('@playwright/test/package.json').version")" + version="$(node -p "try { require('@playwright/test/package.json').version } catch { '' }")" + if [[ -z "$version" ]]; then + echo "::error::Cannot resolve `@playwright/test`. Ensure dependency restore/install runs before Setup Playwright." + exit 1 + fi echo "version=${version}" >> "$GITHUB_OUTPUT" @@ - run: npx playwright install + run: npx --no-install playwright installAlso applies to: line 40
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/actions/setup-playwright/action.yml around lines 23 - 25, Wrap the node invocation that reads `@playwright/test`'s package.json in a small defensive script that fails loudly if the package cannot be resolved (e.g., use a try/catch in node to require('@playwright/test/package.json'), validate the version is non-empty, log the error and exit non-zero instead of emitting an empty version) and change the install invocation to use explicit no-install mode by replacing `npx playwright install` with `npx --no-install playwright install` so the action never auto-installs the tool; update the run block containing `node -p "require('@playwright/test/package.json').version"` and the step that runs `npx playwright install` accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/actions/setup-playwright/action.yml:
- Around line 23-25: Wrap the node invocation that reads `@playwright/test`'s
package.json in a small defensive script that fails loudly if the package cannot
be resolved (e.g., use a try/catch in node to
require('@playwright/test/package.json'), validate the version is non-empty, log
the error and exit non-zero instead of emitting an empty version) and change the
install invocation to use explicit no-install mode by replacing `npx playwright
install` with `npx --no-install playwright install` so the action never
auto-installs the tool; update the run block containing `node -p
"require('@playwright/test/package.json').version"` and the step that runs `npx
playwright install` accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a0a93b06-b60c-4cce-8b81-e97541c08cd4
📒 Files selected for processing (1)
.github/actions/setup-playwright/action.yml
ref #27252 Empty commit to rerun the Playwright app test jobs with the Linux-Playwright-1.58.2 browser cache deleted, so we can verify that the cache-miss path in setup-playwright also finishes quickly (i.e. no apt-get involvement). Will be cleaned up if the verification succeeds.
|
The custom `Setup Playwright` action ran `npx playwright install --with-deps` on cache miss and `npx playwright install-deps` on cache hit. Both shell out to `apt-get`, which has been intermittently hanging GitHub-hosted runners for the full job timeout. The most recent Comments-UI run sat on `Setup Playwright` for ~33 minutes before being cancelled, with every other step finishing in seconds. The same symptom has been observed across the ActivityPub and Admin-X Settings jobs over the past few days. ## Why not the Playwright Docker container An earlier iteration of this PR moved the four jobs into `mcr.microsoft.com/playwright:v<version>-noble` to bypass `apt-get` entirely. That worked locally but failed in CI because `actions/cache` does not share cache between host-runner jobs and container jobs ([actions/cache#1455](actions/cache#1455), [TryGhost#1300](actions/cache#1300)). The `job_setup` cache saved on the host runner was invisible to the container jobs, which then fell through to `install-deps.sh` and failed on `node-gyp` because the Playwright image does not include Python `distutils`. Switching the whole workflow to containers just to satisfy cache scoping was a disproportionate change, so this PR takes the smaller path of fixing the `apt-get` problem directly. ## What the fix does GitHub's `ubuntu-latest` runner image is already provisioned with every system library Playwright's bundled browsers need — libnss3, libgtk, libasound, fonts, etc. — because the image also ships Chrome, Firefox and Edge. There is no reason for the action to go through `apt-get` at all. The new `setup-playwright/action.yml`: - Reads the Playwright version from `@playwright/test` (unchanged) - Restores the `~/.cache/ms-playwright` cache (unchanged) - On cache miss, runs **`npx playwright install`** — no `--with-deps`, no `apt-get` - On cache hit, does nothing — the previous `npx playwright install-deps` step is deleted entirely If a future Playwright release ever needs a new OS library that isn't already on the runner, the tests will fail with a clear `libfoo: cannot open shared object file` error and we can add exactly that package back explicitly, without re-introducing the wildcard `apt-get` path.



Summary
apt-getcode paths from.github/actions/setup-playwrightso the action only downloads Playwright browser binariesAdmin-X Settings,ActivityPub,Comments-UI,Signup-form) onubuntu-latestwith the existingrestore-cacheflowWhy this change
The custom
Setup Playwrightaction rannpx playwright install --with-depson cache miss andnpx playwright install-depson cache hit. Both shell out toapt-get, which has been intermittently hanging GitHub-hosted runners for the full job timeout. The most recent Comments-UI run sat onSetup Playwrightfor ~33 minutes before being cancelled, with every other step finishing in seconds. The same symptom has been observed across the ActivityPub and Admin-X Settings jobs over the past few days.Why not the Playwright Docker container
An earlier iteration of this PR moved the four jobs into
mcr.microsoft.com/playwright:v<version>-nobleto bypassapt-getentirely. That worked locally but failed in CI becauseactions/cachedoes not share cache between host-runner jobs and container jobs (actions/cache#1455, #1300). Thejob_setupcache saved on the host runner was invisible to the container jobs, which then fell through toinstall-deps.shand failed onnode-gypbecause the Playwright image does not include Pythondistutils. Switching the whole workflow to containers just to satisfy cache scoping was a disproportionate change, so this PR takes the smaller path of fixing theapt-getproblem directly.What the fix does
GitHub's
ubuntu-latestrunner image is already provisioned with every system library Playwright's bundled browsers need — libnss3, libgtk, libasound, fonts, etc. — because the image also ships Chrome, Firefox and Edge. There is no reason for the action to go throughapt-getat all.The new
setup-playwright/action.yml:@playwright/test(unchanged)~/.cache/ms-playwrightcache (unchanged)npx playwright install— no--with-deps, noapt-getnpx playwright install-depsstep is deleted entirelyIf a future Playwright release ever needs a new OS library that isn't already on the runner, the tests will fail with a clear
libfoo: cannot open shared object fileerror and we can add exactly that package back explicitly, without re-introducing the wildcardapt-getpath.Testing
js-yaml .github/workflows/ci.yml-> parses cleanlyjs-yaml .github/actions/setup-playwright/action.yml-> parses cleanlySetup Playwrightstep on all four affected jobs