Skip to content

ci: Fix Composer cache and speed up lint - #1330

Merged
gabrielcld2 merged 1 commit into
developfrom
ci/speed-up-ci-workflow
Oct 20, 2026
Merged

gabrielcld2 merged 1 commit into
developfrom
ci/speed-up-ci-workflow

Conversation

@utkarshcloudinary

@utkarshcloudinary utkarshcloudinary commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

No issue. CI speed-up.

Approach

The Composer cache in ci.yml was never used. Every job cached ~/.composer/cache, but Composer on the runner writes to ~/.cache/composer. So each job got "Cache not found" on restore and a "Path Validation Error" on save. This PR fixes the cache, makes PHPCS faster, and cancels superseded PR runs.

  • Read the Composer cache path from composer config cache-files-dir in all four jobs, the same way deploy-to-wp-org.yml already does.
  • Fix the build matrix cache key. It used the undefined matrix.php, so it should be matrix.php-version. The 7.4 and 8.5 jobs now get separate keys.
  • Add a concurrency group that cancels a superseded run when a PR gets a new push. Runs on develop and master pushes are not cancelled.
  • Run PHPCS with --parallel=8 through phpcs.xml.dist. This also makes the lint-staged pre-commit hook faster.

Measured results

Data from run 39405988243: attempt 1 (cold cache) and attempt 2 (warm cache). The baseline is earlier develop/PR runs.

  • Composer cache: all five jobs now restore it (Cache restored from key: Linux-composer-<job>-...), and the save step no longer shows a path error. The time saved is small: composer install takes about 1.5 to 2.5s with the warm cache and about 3 to 5s before.
  • PHPCS in the build jobs: about 25 to 32s on this branch (4 job runs), against about 36 to 62s before (6 job runs on 3 recent runs). Locally, composer lint drops from about 24s to 8s.
  • Total wall time is not changed. It stays at about 5.5 min because the E2E job is the critical path, and this PR does not change it.

Follow-ups (not in this PR)

For the E2E job, about 1.5 min is wp-env start and about 1.8 min is the single-worker @serial pass.

  • Split @serial specs across a 2-shard matrix, each with its own wp-env.
  • Start wp-env with testsEnvironment: false in CI to boot one site instead of two. The E2E and unit setup use the tests containers, so this needs a config and helper change first.

QA notes

  • In any run after the first one on a branch, the "Cache Composer" step should log Cache restored from key: Linux-composer-.... The post step should not show "Path Validation Error".
  • build (7.4) and build (8.5) should use different cache keys (Linux-composer-7.4-... and Linux-composer-8.5-...).
  • Push two commits quickly to a PR. The first run should be cancelled. (Not exercised on this PR.)
  • npm run lint:php locally should give the same result as before, only faster.

The Composer cache never restored or saved. The workflow cached
~/.composer/cache, but Composer on the runner writes to
~/.cache/composer, so every job downloaded all packages again and
logged a "Path Validation Error" on save. Read the real path from
`composer config cache-files-dir`. The build matrix key also used
the undefined `matrix.php`, so both PHP versions shared one key.

Cancel superseded PR runs so a new push does not wait behind an
obsolete one. Pushes to develop and master still run to completion.

Run PHPCS in parallel processes. Locally this cuts `composer lint`
from about 24s to 8s.
@utkarshcloudinary
utkarshcloudinary marked this pull request as draft October 20, 2026 10:10
@utkarshcloudinary
utkarshcloudinary marked this pull request as ready for review October 20, 2026 10:23

@gabrielcld2 gabrielcld2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job 👍

@gabrielcld2
gabrielcld2 merged commit 9e83fe2 into develop Oct 20, 2026
12 checks passed
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.

3 participants