Skip to content

[ci] Chore: cache Playwright's apt packages and skip WebKit deps on Linux - #9085

Merged
etrepum merged 2 commits into
meta:mainfrom
etrepum:claude/playwright-install-deps-cache-ag02eu
Aug 21, 2026
Merged

etrepum merged 2 commits into
meta:mainfrom
etrepum:claude/playwright-install-deps-cache-ag02eu

Conversation

@etrepum

@etrepum etrepum commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Improve the CI performance of setup-playwright (used in e2e and browser unit tests) by caching apt dependencies and installing only the dependencies for the browsers under test (chromium and firefox, explicitly not webkit)

Test plan

A successful CI pair of runs is the test - the first run populated the cache and the next proves that the cache worked.

…inux

## Description

Every Linux CI job runs `pnpm exec playwright install-deps` through
`.github/actions/setup-playwright`, and that step downloads its apt packages
from scratch on every run. Two things make it more expensive than it needs to
be:

- It was invoked with no browser arguments, so it installed the dependency
  closure for all three browsers. WebKit accounts for the large majority of
  those packages, and WebKit is never launched on Linux in this repository —
  `call-e2e-test.yml` guards it behind `os == 'macos-latest'`, the
  `tests-extended.yml` browser matrix only pairs WebKit with macOS, and nothing
  under `examples/` or `scripts/__tests__/integration` references it.
- Nothing was cached, so the same packages were fetched from the Ubuntu archive
  on every job of every run.

This change:

- Adds a `browsers` input (default `chromium firefox`) that is passed to
  `playwright install-deps`, so WebKit's dependency closure is no longer
  downloaded on Linux. A Linux job that does need WebKit can opt back in.
- Redirects apt's archive directory to `${RUNNER_TEMP}/playwright-apt` via a
  drop-in `/etc/apt/apt.conf.d` file and sets
  `APT::Keep-Downloaded-Packages "true"`, then caches the resulting `*.deb`
  files with `actions/cache`. Playwright shells out to a plain
  `apt-get install`, so configuring apt globally is what lets its own
  invocation pick the cache up. On a warm cache apt reports
  `Need to get 0 B` and installs straight from disk.

The cache key covers the distro release, arch, Playwright version and browser
list, plus an ISO-week salt so the stored `.deb` files never drift more than a
week behind the archive index; `restore-keys` falls back to the previous week's
entry so a stale cache still avoids most of the download, and the refreshed set
is saved under the new key.

A prebuilt `mcr.microsoft.com/playwright` container was considered as an
alternative. It was not taken because it only helps the Linux jobs (macOS and
Windows still need the current path), it requires manually keeping the image tag
in sync with the `@playwright/test` version, and with the dependency set reduced
and cached there is little left for it to save.

## Test plan

Measured on an Ubuntu 24.04 container with `[email protected]`, matching
the `ubuntu-latest` runner image.

### Before

`install-deps` with no browser arguments resolves the full three-browser
closure:

    $ node cli.js install-deps --dry-run
    Missing system dependencies (184):
      dictionaries-common
      emacsen-common
      glib-networking
      ...

Broken down by browser on the same pristine container:

    $ node cli.js install-deps --dry-run chromium
    All system dependencies are installed.
    $ node cli.js install-deps --dry-run firefox
    Missing system dependencies (33):
    $ node cli.js install-deps --dry-run webkit
    Missing system dependencies (184):

The WebKit-only remainder is 156 packages / 65.0 MB of downloads on top of the
49 packages / 37 MB that chromium + firefox pull in, so the old invocation
fetched roughly 102 MB per Linux job.

### After

`install-deps chromium firefox` populates the redirected archive directory:

    $ printf 'Dir::Cache::archives "%s";\nAPT::Keep-Downloaded-Packages "true";\n' \
        "$APT_CACHE_DIR" | sudo tee /etc/apt/apt.conf.d/99-playwright-deps-cache
    $ node cli.js install-deps chromium firefox
    ...
    Processing triggers for libc-bin (2.39-0ubuntu8.7) ...

    real    0m24.852s
    $ ls "$APT_CACHE_DIR"/*.deb | wc -l
    49
    $ du -sh "$APT_CACHE_DIR"
    37M

With the archive directory populated (the warm-cache path), apt installs
without touching the network:

    $ apt-get install --reinstall -y --no-install-recommends libavcodec60
    Need to get 0 B/5851 kB of archives.

The composite action's own shell steps were exercised directly: the cache key
computation emits

    dir=<RUNNER_TEMP>/playwright-apt
    restore_key=playwright-apt-v1-ubuntu-24.04-X64-pw1.60.0-chromium+firefox-
    key=playwright-apt-v1-ubuntu-24.04-X64-pw1.60.0-chromium+firefox-2026-34

and the `.deb` counting reports `deb_count=0` for an empty directory (so the
save step is skipped rather than failing on an empty glob) and `deb_count=49`
for the populated one.

The workflows themselves could not be exercised here — GitHub Actions does not
run in this environment, so the cache save/restore round trip and the macOS and
Windows paths (where the new steps are skipped by `runner.os == 'Linux'`) are
unverified until CI runs. `prettier --check` passes on the changed file.
@vercel

vercel Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 20, 2026 9:49pm
lexical-playground Ready Ready Preview Aug 20, 2026 9:49pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 20, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Aug 20, 2026
@etrepum
etrepum added this pull request to the merge queue Aug 21, 2026
Merged via the queue into meta:main with commit 08c69f4 Aug 21, 2026
76 of 77 checks passed
@etrepum
etrepum deleted the claude/playwright-install-deps-cache-ag02eu branch August 21, 2026 15:30
unix-max pushed a commit to unix-max/lexical that referenced this pull request Aug 28, 2026
@etrepum etrepum mentioned this pull request Aug 31, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — d1a9d66f Deployed Aug 20, 2026 by vercel[bot]
Preview – lexical-playground — d1a9d66f Deployed Aug 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants