Skip to content

Cache Composer downloads in the CI workflows - #376

Merged
jakejackson1 merged 1 commit into
gravitypdffrom
fix/353-composer-cache
Sep 23, 2026
Merged

jakejackson1 merged 1 commit into
gravitypdffrom
fix/353-composer-cache

Conversation

@jakejackson1

Copy link
Copy Markdown
Member

Closes #353.

Every workflow ran composer install from a cold cache, and tests.yml alone runs 24 matrix jobs per push.

Changes

tests.yml, snapshots.yml, cs.yml, static-analysis.yml and coverage.yml each gain two steps before "Install dependencies":

  1. Locate Composer cache — reads composer config cache-files-dir in a bash shell so the Windows jobs resolve it too.
  2. Cache Composer downloads — actions/cache@v6 on that directory.

Key: composer-<os>-php<version>-<extras>-<hash of composer.json>, restoring from the same prefix without the hash (there is no composer.lock). <extras> is font-bundle-lite for tests/coverage and phpstan for static-analysis. The cache is saved at the end of the job, so it also holds the packages required after the install. Having their names in the key stops jobs in different workflows that share an OS and PHP version from overwriting each other's cache.

Notes

  • A cache hit is never saved again. If mpdf/font-bundle-lite or phpstan releases a new version while composer.json is unchanged, that one package is downloaded on each run until composer.json changes.
  • conformance.yml (Write PDF/A-2b and PDF/A-2u documents that keep their transparency #330) isn't on gravitypdf yet, so it isn't touched here. Whichever PDF/A branch lands later needs the same two steps.
  • coverage.yml only runs on development/coverage pushes. It is changed anyway so all the workflows match.

Testing

  • All five files parse as YAML. actionlint reports nothing in the new lines. Its only report, SC2016 on "Let Imagick read PDFs", was there before and is intended.
  • The first run on this PR fills the caches. A re-run should show "Cache restored" in the "Cache Composer downloads" step.

🤖 Generated with Claude Code

Every job ran composer install from a cold cache, and tests.yml alone
runs 24 matrix jobs per push. Each workflow now restores Composer's
cache-files-dir with actions/cache before installing, keyed on the
runner OS, the PHP version and composer.json (there is no composer.lock).
The directory is read in a bash step so the Windows jobs resolve it too.

The cache is saved at the end of the job, so the packages required
after the install (mpdf/font-bundle-lite, phpstan/phpstan) are in it as
well; their names go in the key so jobs that share an OS and PHP version
across workflows do not overwrite each other's cache.

Closes #353

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jakejackson1
jakejackson1 merged commit 1854766 into gravitypdf Sep 23, 2026
52 checks passed
@jakejackson1
jakejackson1 deleted the fix/353-composer-cache branch September 30, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-upstream-pr enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache Composer downloads in the CI workflows

1 participant