Speed up CI with targeted caching and fewer jobs#951
Merged
Conversation
Speeds up CI runs by caching the expensive downloads and scan results that were previously repeated on every run: Playwright browsers keyed on the installed version, wp-env WordPress/tarball downloads, the PHPCS results file, and the ESLint/Jest caches. Also collapses the separate build and test jobs in the E2E workflow into a single job (the artifact hand-off added runner provisioning without enabling parallelism), and swaps the global wp-env install in integration for an npx invocation backed by setup-node's npm cache.
The composer test:integration scripts invoke wp-env directly, relying on it being on PATH. The previous global npm install satisfied that; switching to npx wp-env did not, since bare wp-env was still unresolved when composer ran its script. Adding node_modules/.bin to GITHUB_PATH keeps the composer scripts working without a global install or changes to composer.json.
Two parts of the earlier speedup didn't pay off and are backed out here. The wp-env download cache broke E2E: the afterStart lifecycle script (wp plugin install query-monitor --activate) consistently failed with "The site you have requested is not installed" on fresh runs, suggesting the cache step interacts badly with wp-env's state directory on first use. Integration tests were unaffected but the cache was always the lowest-value item in the plan, so it goes from both workflows. The global-install to npx swap in integration pushed a full npm ci into the job that previously only fetched wp-env, adding around 25 seconds and pushing total runtime from ~2m20s to ~4m. Reverting to npm -g install @wordpress/env restores the original speed; the companion PATH tweak for composer scripts is no longer needed. The Playwright cache, PHPCS cache, ESLint/Jest cache, and the merged E2E build+test job remain in place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CI runs were repeating expensive work on every push. This branch keeps the repeat work that can be safely skipped and leaves the rest alone after two of the original changes didn't pan out on live CI.
What's kept: the Playwright browsers are cached and keyed on the installed
@playwright/testversion so the ~150 MB download is only repeated when the package version bumps. On a cache hit we still runplaywright install-depsso system libraries are in place on a fresh runner. PHPCS writes to.phpcs-cacheand the file is persisted between runs, letting it skip unchanged files. ESLint gains--cacheand Jest's transform cache is persisted too. The E2E workflow's separatebuildandtestjobs are merged into one — the artefact hand-off they did only pays off when multiple test jobs consume the build, which isn't the case here, so splitting them was costing a second runner's provisioning for no parallelism.What was tried and reverted: the wp-env download cache consistently broke the E2E workflow, where the
afterStartlifecycle hook reported the dev site wasn't installed on fresh runs. Rather than debug further, the cache is dropped from both workflows (it was the lowest-value item in the plan anyway). Swapping the integration workflow's globalnpm -g install @wordpress/envfornpxpushed a fullnpm ciinto the job that previously only fetched one package, adding around 25 seconds and nearly doubling the total runtime; that swap is also reverted.First CI run after this change will be slightly slower as the retained caches populate. Subsequent runs should see meaningful savings on E2E in particular (browser download skipped, one runner instead of two).
Test plan
.phpcs-cacheis cold vs warm--cacheenabled