-
Notifications
You must be signed in to change notification settings - Fork 582
Keep the result cache when composer.lock changes but no package version did #6086
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
Changes from all commits
bdca7e2
a82d77d
9ce1fc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -379,6 +379,40 @@ jobs: | |
| OUTPUT=$(../bashunit -a exit_code "1" "../../bin/phpstan analyse -vv --error-format raw") | ||
| echo "$OUTPUT" | ||
| ../bashunit -a contains 'ClassUsingDefine.php:13:Method ResultCacheE2EDefine\ClassUsingDefine::getMode() should return int<1, 3> but returns 5. [identifier=return.type]' "$OUTPUT" | ||
| - script: | | ||
| cd e2e/result-cache-composer-lock | ||
| composer install | ||
| ../../bin/phpstan analyse | ||
| # Change composer.lock without changing any installed package version/reference | ||
| # (vendor/composer/installed.php is left untouched), like a regenerated lock in CI | ||
| # when composer.lock is not committed. The result cache must be kept, not discarded. | ||
| jq '.["content-hash"]="0000000000000000000000000000000000000000"' composer.lock > composer.lock.new | ||
| mv composer.lock.new composer.lock | ||
| OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") | ||
| echo "$OUTPUT" | ||
| ../bashunit -a contains 'Composer metadata changed but no package versions changed; keeping the result cache.' "$OUTPUT" | ||
| ../bashunit -a contains 'Result cache restored. 0 files will be reanalysed.' "$OUTPUT" | ||
|
Comment on lines
+389
to
+394
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add another test in which we change the content hash and in addition a single php file.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a test which verifies the cache gets invalidated, after we updated a single package?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in a82d77d:
|
||
| # Change the content hash again AND edit a single source file: the cache is still kept | ||
| # (no package changed), and only the one changed file is reanalysed. | ||
| printf '\n' >> src/Foo.php | ||
| jq '.["content-hash"]="1111111111111111111111111111111111111111"' composer.lock > composer.lock.new | ||
| mv composer.lock.new composer.lock | ||
| OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") | ||
| echo "$OUTPUT" | ||
| ../bashunit -a contains 'Composer metadata changed but no package versions changed; keeping the result cache.' "$OUTPUT" | ||
| ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" | ||
| - script: | | ||
| cd e2e/result-cache-package-update | ||
| composer install | ||
| ../../bin/phpstan analyse | ||
| # Simulate a single Composer package being updated by changing its recorded reference in | ||
| # vendor/composer/installed.php. The cache must be invalidated only for files depending on | ||
| # that package (src/Foo.php uses psr/log), not for the whole project. | ||
| php -r '$f = "vendor/composer/installed.php"; $d = require $f; $d["versions"]["psr/log"]["reference"] = "0000000000000000000000000000000000000000"; file_put_contents($f, "<?php return " . var_export($d, true) . ";" . PHP_EOL);' | ||
| OUTPUT=$(../bashunit -a exit_code "0" "../../bin/phpstan analyse -vv") | ||
| echo "$OUTPUT" | ||
| ../bashunit -a contains 'Composer packages changed (psr/log); re-analysing only the files depending on them.' "$OUTPUT" | ||
| ../bashunit -a contains 'Result cache restored. 1 file will be reanalysed.' "$OUTPUT" | ||
| - script: | | ||
| cd e2e/bug-12606 | ||
| export CONFIGTEST=test | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /vendor | ||
| /composer.lock |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "phpstan/result-cache-composer-lock-e2e", | ||
| "autoload": { | ||
| "classmap": ["src"] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| parameters: | ||
| level: 5 | ||
| tmpDir: tmp | ||
| paths: | ||
| - src |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?php | ||
|
|
||
| namespace ResultCacheComposerLockE2E; | ||
|
|
||
| class Foo | ||
| { | ||
|
|
||
| public function doFoo(): int | ||
| { | ||
| return 1; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| * | ||
| !.* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /vendor | ||
| /composer.lock |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "phpstan/result-cache-package-update-e2e", | ||
| "require": { | ||
| "psr/log": "^3.0" | ||
| }, | ||
| "autoload": { | ||
| "classmap": ["src"] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| parameters: | ||
| level: 5 | ||
| tmpDir: tmp | ||
| paths: | ||
| - src |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| namespace ResultCachePackageUpdateE2E; | ||
|
|
||
| use Psr\Log\LoggerInterface; | ||
|
|
||
| class Foo | ||
| { | ||
|
|
||
| public function __construct(private LoggerInterface $logger) | ||
| { | ||
| } | ||
|
|
||
| public function doFoo(): void | ||
| { | ||
| $this->logger->info('hello'); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| * | ||
| !.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also update these tests to use a patch file instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to. Since #6086 is already merged, do you want this as a separate follow-up PR?
result-cache-package-updateconverts cleanly to the #6088 patch-file style.result-cache-composer-lockhas a small wrinkle I'd like to talk through (itscomposer.lockis gitignored now, so there's nothing for a patch to apply against), but that can wait until you confirm you want the follow-up.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please followup