Sharing the Composer cache in GitHub Actions made PHPUnit integration tests 31% faster

DanielLockyer · x · 2026-11-22

Developer DanielLockyer merged a PR into PHPCSStandards/composer-installer that shares one Composer cache across integration tests in GitHub Actions, cutting Ubuntu jobs from 2–3 min to 1–2 min (31% faster overall) and speeding up Windows jobs by 8%.

The root cause: each test created a fresh COMPOSERHOME, so with no COMPOSERCACHEDIR set, Composer's cache landed inside it and every test re-downloaded Packagist metadata and archives. The fix sets COMPOSERCACHEDIR to .cache/composer via putenv() in tests/bootstrap.php, leaving pre-existing values untouched, and adds /.cache/ to .gitignore.

Related event: Sharing Composer cache across CI tests speeds up PHPUnit integration tests by 31%(2 posts)→

Original post →

More from coding & agent

coding & agent channel →