We use the tool PHPStan to perform static analysis on our codebase. We've defined a custom cache as follows and are using it in a step in our pipeline.
definitions:
caches:
phpstan:
key:
files: # the files you want pipelines to check for changes when deciding whether to use the cache, or download fresh dependencies.
- composer.lock
path: tmp # same as in phpstan.neon
pipelines:
default:
- step:
name: Static Analysis
script:
- composer install
- vendor/bin/phpstan
caches:
- composer
- phpstan
We can see that when the step succeeds (there are no static analysis warnings) the cache step proceeds and saves the cache if necessary.
The desired behavior is to save and upload the phpstan cache even if the pipeline step fails. If there are only errors in one file, then the entire cache apart from that one file is valid and can be reused in a later pipeline run once the errors in the single file have been resolved.
We can "trick" the pipeline by changing `vendor/bin/phpstan` to `vendor/bin/phpstan || exit 0` which allows the cache to be saved, but obviously masks any errors that occurred during the step.
Both Github and Gitlab allow caching steps to run even if the step/action fails PHPStan CI Documentation
Is there analogous behavior in Bitbucket?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.