ci: cache PHPStan's result cache between runs#2191
Open
SanderMuller wants to merge 1 commit into
Open
Conversation
The PHPStan static-analysis job ran with a cold cache on every push and PR, re-analysing the whole codebase each time, because PHPStan's tmpDir (.cache/phpstan) was not persisted between runs. Restore the cache before the run and save it afterwards (with `if: !cancelled()` so it is written even when PHPStan exits non-zero on findings), following PHPStan's documented CI recipe. `.cache/` is already gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
|
Not sure if this is necessary, we're planning on fully moving to Mago. @brendt, what do you think? |
Member
|
Even if we migrate to Mago soon, it's nice to have this in the meantime imo |
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.
The PHPStan static-analysis job currently runs with a cold cache on every push and PR. It re-analyses the whole codebase each time, because PHPStan's
tmpDir(.cache/phpstan) isn't persisted between runs.This caches it with PHPStan's documented CI recipe: restore the cache before the run, and save it afterwards with
if: ${{ !cancelled() }}so it's still written when PHPStan exits non-zero on findings..cache/is already gitignored, so nothing else changes.Effect:
composer updateinvalidates the result cache, PHPStan keeps a separate content-hash-keyed reflection cache in the same directory, so those runs stay faster too. (Locally, a result-cache-invalidated run ofpackages/still used about 18% less CPU; no-change runs become near-instant.)Results are unchanged: PHPStan invalidates the cache per file by content hash, and wholesale on a PHP or PHPStan version change.
Ref: https://phpstan.org/user-guide/result-cache