Cache on successful file processing#3614
Conversation
|
|
||
| if ($errorAndFileDiffs[Bridge::SYSTEM_ERRORS] !== []) { | ||
| $this->changedFilesDetector->invalidateFile($file->getFilePath()); | ||
| } elseif (! $configuration->isDryRun()) { |
There was a problem hiding this comment.
here the added condition
|
|
||
| if ($systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS] !== []) { | ||
| $this->changedFilesDetector->invalidateFile($file->getFilePath()); | ||
| } elseif (! $configuration->isDryRun()) { |
There was a problem hiding this comment.
here the added condition
|
I think this one need e2e test to avoid regression and back and forth check, eg:
if ($a && $b) {
return true;
}on config: <?php
declare(strict_types=1);
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(ChangeAndIfToEarlyReturnRector::class);
$rectorConfig->rule(NewlineAfterStatementRector::class);
};First: https://getrector.com/demo/55b308a8-af17-48cb-b2be-9c0d26ab60c4 |
|
Thanks for guidance! Will work on separate PRs this week-end to add those e2e tests |
f8f8588 to
ceac622
Compare
|
Is this still WIP ? |
|
It needs one more e2e test for consecutive succesfull. for consecutive dry-run, there was already PR #3616 |
|
I planned to work on that e2e test this week-end |
|
@samsonasik @staabm here it is: #3666 |
1e5b832 to
e9fbade
Compare
e9fbade to
092b701
Compare
| @@ -32,7 +32,7 @@ public function testHasFileChanged(): void | |||
| $filePath = __DIR__ . '/Source/file.php'; | |||
There was a problem hiding this comment.
why are these test-changes required?
existing tests shouldn't be changed with new PRs
There was a problem hiding this comment.
because previous logic is splitted in 2 methods now, I renamed one so maybe it's clearer
092b701 to
58e34f2
Compare
|
I think the PR itself needs a new test-case reproducing the issue it is trying to fix |
c323a5e to
a6d89fc
Compare
|
@staabm good point! I'll try to come with a test in following days, but the final code is ready if you want to have a look, see that all tests pass now, even the consecutive runs test. Credits to @stof for the idea! Thank you |
a6d89fc to
7635179
Compare
|
Please rename commit message with double quote |
7635179 to
2e10efa
Compare
|
@samsonasik that revert commit is a temporary one just to generate a failing build, to show the issue. |
2e10efa to
489b03b
Compare
|
Here the failing test without the fix: https://github.com/rectorphp/rector-src/actions/runs/4850942011/jobs/8644319975?pr=3614 |
There was a problem hiding this comment.
we expect the timeout error to stay even with cache, and now the timouted files are not cached because we cache on success instead of caching at the beginning of the processing
|
|
||
| return static function (RectorConfig $rectorConfig): void { | ||
| $rectorConfig->cacheClass(FileCacheStorage::class); | ||
| $rectorConfig->parallel(1); |
There was a problem hiding this comment.
used 1 second timeout to maximize chances of timeout
| __DIR__ . '/src', | ||
| ]); | ||
|
|
||
| $rectorConfig->sets([LevelSetList::UP_TO_PHP_82]); |
There was a problem hiding this comment.
used a big rule set to maximize chances of timeout
There was a problem hiding this comment.
used a big file from src to maximize chances of timeout
|
@TomasVotruba @samsonasik @staabm this is now ready for review! |
489b03b to
b7bc6c4
Compare
b7bc6c4 to
53cfe73
Compare
53cfe73 to
cba16d3
Compare
cba16d3 to
cc2811b
Compare
|
Thank you 👍 |
|
I think we need the same fix in https://github.com/easy-coding-standard/easy-coding-standard. @yguedidi could you check that? |
|
@staabm I'm not using ECS, so I can't guarantee that I can come with a PR any time soon there sorry. |
New version of #3604
Closes rectorphp/rector#7770
Now a file will be cached only when not in dry run mode
needs first: