Skip to content

Add the playwright module: cached browsers, and system packages with a .deb cache only main saves - #60

Open
ndbroadbent wants to merge 4 commits into
modules/nodefrom
modules/playwright
Open

ndbroadbent wants to merge 4 commits into
modules/nodefrom
modules/playwright

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Stacked on #54 (the node module). Its base is modules/node; retarget it to main once #54 merges.

What it adds

The playwright module (GitHub Actions only). It's listed after node: modules: [node, playwright].

  • It reads the installed Playwright's version (<exec> playwright --version) and fails if Playwright isn't installed, instead of letting npx download the latest. <exec> is npx, pnpm exec or yarn, picked by the package manager.
  • It caches ~/.cache/ms-playwright, keyed by OS, arch, Playwright's version and the browsers.
  • On Linux, with deb_cache (on by default):
    • It restores ~/.cache/playwright-debs, keyed by arch, a checksum of /etc/os-release, the version and the browsers. The fallback is the newest cache for the same OS release.
    • It points apt's archive directory there with Keep-Downloaded-Packages, then runs playwright install-deps.
    • An always() step removes the apt config, chowns the directory, and prunes every .deb whose package isn't installed at exactly that version.
    • actions/cache/save runs only on refs/heads/<save_branch>, only after a non-exact restore, and only when a .deb is left. PRs and other branches read main's cache and never write their own.
  • playwright install <browsers> gets --with-deps only when deb_cache is off.
  • Inputs: package.json, the lockfile (which pins Playwright) and playwright.config.*, all in path.

ModuleSpec gains requires: the modules a job must list before this one. [playwright] or [playwright, node] now fails generation with "list node before it in the job's modules:".

mockci gives each job its own empty HOME (a separate commit), as a hosted runner does. CARGO_HOME and RUSTUP_HOME still point at the host's toolchain. actions/cache can now cache ~/ paths, resolved under that HOME. Before this change, mockci rejected any ~ path, so a module whose caches live in HOME couldn't be simulated.

Tests

  • tests/module_playwright.rs (mockci), with fake pnpm, sudo, dpkg-deb and dpkg-query:
    • A skipped job installs nothing.
    • Changing playwright.config.ts, the lockfile, package.json or the parameters reruns the job.
    • The .deb cache lifecycle:
      • A PR before main has a cache downloads and saves nothing.
      • main saves.
      • A later PR restores main's cache (hit) and saves nothing.
      • main with an exact hit saves nothing.
      • A Playwright bump restores the older cache through the prefix (partial) and saves under the new key.
    • A stale .deb is pruned before saving.
  • I checked that the tests catch real breakage by mutating the module:
    • Dropping the github.ref gate fails the branch test.
    • Dropping playwright.config.* from the inputs fails the inputs test.
  • tests/mockci_home.rs: each job has its own HOME, and a ~/ path round-trips through the cache.
  • Unit tests:
    • the step layout and cache keys;
    • deb_cache: false and system_deps: false;
    • npm with path and a custom save_branch;
    • error messages;
    • the requires ordering.
  • Golden fixture integration_tests/module_playwright/. The catalogue and schemas are regenerated.

Docs

  • src/modules/playwright/README.md and SKILL.md.
  • A Playwright section in docs/.../modules.md.
  • README, the homepage (chip and the coming-soon list), and STATUS.
  • The bootstrap case study line now says both modules exist.

Prove it works
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

`modules: [node]` installs the Node the project pins and its package
manager, runs a frozen install and caches the package manager's
downloads, on GitHub Actions and CircleCI.

- Node's version: .nvmrc or .node-version in `path`, else at the root,
  else package.json's engines.node, else `version:` (or `preinstalled`).
  On CircleCI the job's image must be a node/cimg/node image matching
  the pinned version.
- Package manager: package.json's packageManager, else the one lockfile
  present. pnpm and Yarn go through pnpm/action-setup or Corepack.
- Install: npm ci, pnpm install --frozen-lockfile, yarn install
  --immutable (Berry) or --frozen-lockfile (Classic).
- Cache: setup-node's cache keyed on the lockfile on GitHub;
  restore_cache/save_cache keyed on the lockfile's checksum on CircleCI.
- Inputs: package.json files, lockfiles, pnpm-workspace.yaml, .npmrc,
  Yarn config and patches, and the version file.

Tests: unit tests for detection, expansion and every mistake; a golden
fixture for both providers; mockci scenarios that a skipped job installs
nothing and that each contributed input and the parameters rerun it.
…h; always install the pinned Corepack; set pnpm 11's store dir

This branch has not been deployed

No deployments
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