Skip to content

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

Merged
Hug0-Drelon merged 10 commits into
e2e-action-inputsfrom
e2e-action-cache
Jul 17, 2026
Merged

perf(e2e): improve node_modules, Playwright and wp-env home caching#20
Hug0-Drelon merged 10 commits into
e2e-action-inputsfrom
e2e-action-cache

Conversation

@Hug0-Drelon

@Hug0-Drelon Hug0-Drelon commented Jul 16, 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 (restore + docker load was slower than it helped).

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.
  • Optional wp-env-cache-key input for consumers whose env content is not fully reflected in .wp-env.json (e.g. WooCommerce version / Polylang Pro SHA).

Depends on the inputs PR (e2e-action-inputs); retarget to main after that merges.
Split from #17 (cache only).

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.

@Hug0-Drelon Hug0-Drelon self-assigned this Jul 16, 2026
@Hug0-Drelon Hug0-Drelon added the enhancement New feature or request label Jul 16, 2026
`status --json` is only available in @wordpress/env 11+; older versions still expose install-path.
require() looked up packages from the action script path, not the repo root.
Use npm ci when package-lock.json is present; otherwise npm install.
Avoid hashing the lockfile just to decide whether to generate it.
Restore and docker load cost more than they save; wp-env start stays slow either way.
Reuse downloaded WordPress sources across CI runs; pin WP_ENV_HOME for snap-safe path.
Restored workdirs keep config_checksum while MySQL volumes are empty, so skip install breaks REST.
@Hug0-Drelon Hug0-Drelon changed the title perf(e2e): improve node_modules, Playwright and wp-env docker caching perf(e2e): improve node_modules, Playwright and wp-env home caching Jul 17, 2026
@Hug0-Drelon
Hug0-Drelon merged commit 1fe48f0 into e2e-action-inputs Jul 17, 2026
@Hug0-Drelon
Hug0-Drelon deleted the e2e-action-cache branch July 17, 2026 11:32
@Hug0-Drelon
Hug0-Drelon restored the e2e-action-cache branch July 17, 2026 12:32
Hug0-Drelon added a commit that referenced this pull request Jul 17, 2026
@Hug0-Drelon

Copy link
Copy Markdown
Member Author

This PR was merged into the wrong base (e2e-action-inputs). That merge was reverted on the inputs branch; the cache work is reopened against main in a follow-up PR (cache-only, independent of #19).

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