Skip to content

perf(e2e): improve node_modules, Playwright and wp-env home caching#21

Merged
Hug0-Drelon merged 1 commit into
mainfrom
e2e-action-cache
Jul 17, 2026
Merged

perf(e2e): improve node_modules, Playwright and wp-env home caching#21
Hug0-Drelon merged 1 commit into
mainfrom
e2e-action-cache

Conversation

@Hug0-Drelon

@Hug0-Drelon Hug0-Drelon commented Jul 17, 2026

Copy link
Copy Markdown
Member

What?

Improve e2e CI caching for node_modules, Playwright browsers, and the wp-env home directory (downloaded WordPress sources).

Why?

More reliable cache keys and reuse of wp-env downloads reduce CI time without relying on a Docker image tarball. Saving all runner images with docker save also exhausts disk on GitHub-hosted runners (see polylang-wc e2e failures).

Reopened against main after #20 was accidentally merged into e2e-action-inputs (inputs PR #19) and then reverted there. This PR is cache-only; it does not include wp-env-config-path / playwright-cmd.

How?

  • Add a Get Node.js version step and include package.json in the node_modules cache key.
  • Resolve @playwright/test version via bin/get-playwright-version.js (from consumer cwd) and add Playwright restore-keys.
  • Skip npm install --package-lock-only when package-lock.json already exists; use npm ci when a lockfile is present.
  • Pin WP_ENV_HOME, cache that directory, and on cache hit delete wp-env-cache.json so wp-env re-runs wp core install against fresh MySQL volumes while keeping downloaded sources.
  • Drop the previous wp-env Docker image tar cache.
  • Replace container-cache-key with optional wp-env-cache-key for consumers whose env content is not fully reflected in .wp-env.json (e.g. WooCommerce version / Polylang Pro SHA).

Test plan

  • Cold cache: wp-env home miss → start + tests pass; cache is saved.
  • Warm cache: home hit → wp-env-cache.json removed → start reconfigures → tests pass (REST API / global setup OK).
  • Change package.json / lockfile and confirm node_modules cache misses.
  • Confirm Playwright binaries restore via exact key or restore-keys.
  • Confirm wp-env home cache key changes when .wp-env.json, WP latest, @wordpress/env version, or wp-env-cache-key changes.
  • With a committed package-lock.json, confirm lockfile generation is skipped.
  • Confirm no docker save step runs (avoids disk exhaustion).

Drop the Docker image tar cache (save of all runner images fills the disk).
Cache ~/.wp-env instead, with optional wp-env-cache-key for consumers whose
env content is not fully reflected in .wp-env.json.
@Hug0-Drelon Hug0-Drelon self-assigned this Jul 17, 2026
@Hug0-Drelon Hug0-Drelon added the enhancement New feature or request label Jul 17, 2026
@Hug0-Drelon
Hug0-Drelon merged commit 7449b04 into main Jul 17, 2026
@Hug0-Drelon
Hug0-Drelon deleted the e2e-action-cache branch July 17, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant