Skip to content

Stop Setup Playwright from hanging on apt-get - #27252

Merged
ErisDS merged 4 commits into
mainfrom
fix/playwright-container-jobs
Apr 9, 2026
Merged

ErisDS merged 4 commits into
mainfrom
fix/playwright-container-jobs

Conversation

@ErisDS

@ErisDS ErisDS commented Apr 8, 2026 •

Copy link
Copy Markdown
Member

Summary

  • remove both apt-get code paths from .github/actions/setup-playwright so the action only downloads Playwright browser binaries
  • keep the four affected app test jobs (Admin-X Settings, ActivityPub, Comments-UI, Signup-form) on ubuntu-latest with the existing restore-cache flow

Why this change

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, #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.

Testing

  • js-yaml .github/workflows/ci.yml -> parses cleanly
  • js-yaml .github/actions/setup-playwright/action.yml -> parses cleanly
  • The CI run on this PR will exercise the fixed Setup Playwright step on all four affected jobs

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.
@coderabbitai

coderabbitai Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

The Playwright setup composite action is updated to remove the man-db trigger refresh disabling step. The Playwright installation behavior is simplified to always run npx playwright install without conditionally executing OS dependency installation based on cache hits. The version output is now written via a shell variable to $GITHUB_OUTPUT using properly quoted paths and variables. The cache verification step is reorganized so actions/cache@v5 is nested under a named step, and cache key formatting is adjusted for consistent spacing in the expression.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removing apt-get calls that cause hangs from the Setup Playwright action.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the problem, solution, and rationale for the fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/playwright-container-jobs

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8d71e79 and 5fc07fc.

📒 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

Comment thread .github/workflows/ci.yml Resolved
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

codecov Bot commented Apr 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.45%. Comparing base (02ba4c3) to head (627756d).
⚠️ Report is 15 commits behind head on main.

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           
Flag Coverage Δ
admin-tests 54.37% <ø> (ø)
e2e-tests 73.45% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
@ErisDS ErisDS changed the title Run Playwright app tests inside the official Playwright container Stop Setup Playwright from hanging on apt-get Apr 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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-cache action provides a fallback that runs yarn install on cache miss (via install-deps.sh), hardening these two lines makes failures more explicit and prevents unexpected behavior:

  • Line 24 assumes @playwright/test is resolvable; if dependency restore drifts or an edge case occurs, a silent empty version string could mask the issue.
  • Line 40's npx playwright install could attempt auto-installation if the local package isn't found; --no-install makes 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 install

Also 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

📥 Commits

Reviewing files that changed from the base of the PR and between ba09c8b and c4c8eac.

📒 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.
@sonarqubecloud

sonarqubecloud Bot commented Apr 9, 2026

Copy link
Copy Markdown

@ErisDS
ErisDS merged commit 48dd568 into main Apr 9, 2026
40 checks passed
@ErisDS
ErisDS deleted the fix/playwright-container-jobs branch April 9, 2026 05:17
franky19 pushed a commit to franky19/Ghost that referenced this pull request Apr 18, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant