Skip to content

Speed up CI with targeted caching and fewer jobs#951

Merged
GaryJones merged 3 commits intodevelopfrom
GaryJones/ci-speedup
Apr 24, 2026
Merged

Speed up CI with targeted caching and fewer jobs#951
GaryJones merged 3 commits intodevelopfrom
GaryJones/ci-speedup

Conversation

@GaryJones
Copy link
Copy Markdown
Contributor

@GaryJones GaryJones commented Apr 24, 2026

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/test version so the ~150 MB download is only repeated when the package version bumps. On a cache hit we still run playwright install-deps so system libraries are in place on a fresh runner. PHPCS writes to .phpcs-cache and the file is persisted between runs, letting it skip unchanged files. ESLint gains --cache and Jest's transform cache is persisted too. The E2E workflow's separate build and test jobs 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 afterStart lifecycle 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 global npm -g install @wordpress/env for npx pushed a full npm ci into 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

  • First run populates Playwright, PHPCS, and ESLint/Jest caches without errors
  • Second run shows cache hits for each
  • PHPCS still reports violations correctly when .phpcs-cache is cold vs warm
  • Integration runtime is back to the baseline (~2m20s)
  • ESLint still fails the job on lint errors with --cache enabled

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.
@GaryJones GaryJones requested a review from a team as a code owner April 24, 2026 01:47
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.
@GaryJones GaryJones added this to the Next milestone Apr 24, 2026
@GaryJones GaryJones self-assigned this Apr 24, 2026
@GaryJones GaryJones added the type: maintenance Routine maintenance and code quality improvements label Apr 24, 2026
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.
@GaryJones GaryJones merged commit 8eabe4e into develop Apr 24, 2026
10 checks passed
@GaryJones GaryJones deleted the GaryJones/ci-speedup branch April 24, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: maintenance Routine maintenance and code quality improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant