Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PHPSTAN_FAIL_WITHOUT_RESULT_CACHE env var #2611

Merged
merged 5 commits into from
Sep 8, 2023

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Sep 8, 2023

to allow testing of the result-cache lets add a new env var a new cli option, which we can use to instruct phpstan to exit with code=2, when the result cache was not used

see phpstan/phpstan#9857 (comment)

partly reverts #2608


➜  bug8778 git:(bug8778) ../../phpstan clear-result-cache -q; ../../phpstan analyse -q                                            
➜  bug8778 git:(bug8778) ../../../phpstan-src/bin/phpstan analyse -vvv --generate-baseline --fail-without-result-cache
Note: Using configuration file /Users/staabm/workspace/phpstan/e2e/bug8778/phpstan.neon.
Result cache not used because the metadata do not match.
 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%  1 sec/1 sec 

Result cache is saved.

                                                                                                                        
 [OK] Baseline generated with 1 error.                                                                                  
                                                                                                                        

Used memory: 78 MB
➜  bug8778 git:(bug8778) echo $?
2

staabm added a commit to staabm/phpstan that referenced this pull request Sep 8, 2023
@ondrejmirtes
Copy link
Member

I agree that the error formatter was the wrong direction. But instead of env variable, I'd prefer --fail-without-result-cache CLI option :)

@staabm
Copy link
Contributor Author

staabm commented Sep 8, 2023

here you are

➜  bug8778 git:(bug8778) ../../phpstan clear-result-cache -q; ../../phpstan analyse -q                                            
➜  bug8778 git:(bug8778) ../../../phpstan-src/bin/phpstan analyse -vvv --generate-baseline --fail-without-result-cache
Note: Using configuration file /Users/staabm/workspace/phpstan/e2e/bug8778/phpstan.neon.
Result cache not used because the metadata do not match.
 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%  1 sec/1 sec 

Result cache is saved.

                                                                                                                        
 [OK] Baseline generated with 1 error.                                                                                  
                                                                                                                        

Used memory: 78 MB
➜  bug8778 git:(bug8778) echo $?
2

@ondrejmirtes ondrejmirtes merged commit 2cb2f07 into phpstan:1.10.x Sep 8, 2023
409 of 413 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the fail-if-no-result-cache branch September 8, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants