-
-
Notifications
You must be signed in to change notification settings - Fork 686
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
Fully populate the cache when running vendor/bin/rector process --dry-run #7932
Comments
On CI, cache is default to You may need to define the Rector cache class, see: |
@samsonasik I do have $rectorConfig->cacheClass(FileCacheStorage::class);
$rectorConfig->cacheDirectory('./temp/rector'); My setup working correctly in terms of where it is writing the cache, the problem is that the content of the cache is different when running:
vs:
|
I see, that's seems expected.
rector/packages/Parallel/WorkerRunner.php Lines 117 to 119 in 1b9a810
see these e2e test for multiple run |
Not sure if I understand this correctly, so are you saying that if the first --dry-run would generate the cache, that would that cause following --dry-run which would use that cache to end with different result? |
No, multiple The cache is applied, just not insert "changed diff" into cache. There is also test for multiple refactor to keep change the file with invalidate changed files so it can apply the change. |
@dorrogeray for some context, the recent changes to the way cache works were made in rectorphp/rector-src#3614 to solve #7770 Important note: @samsonasik by writing the above I realize, as full processing got rejected, and so we cache only unchanged files, maybe we can also cache those files in dry run mode? |
I think that this would be the right solution. From the use-case perspective I have described, if I have empty cache, and run rector with --dry-run twice, and no files require any changes, the second --dry-run should "essentially do nothing" because it will have everything cached from the first run. Currently, both dry runs run from scratch. |
That will confusing if first run show the diff and second run not show anything, that was the behaviour that fixed in the past. Cache improvement is fine as far as it doesn't make bad DX. |
@samsonasik a file showing a diff is a changed file, and so it will not be cached. so in the second run it should appear again |
That's what I meant, first and second run should show the same result. That's the current e2e show. |
Here how cache works:
|
Thanks for the feedback, I will try to prepare a PR. |
I let you take it @dorrogeray then! Feel free to ping me when ready |
@yguedidi I have prepared a PR here: rectorphp/rector-src#3834 |
Fixed in rectorphp/rector-src#4281 |
Feature Request
When running rector in
vendor/bin/rector process --dry-run
, the cache should be fully populated, just like when running rector without the--dry-run
flag. The use case is that in the CI, you would ideally want to run rector with--dry-run
, since that will return non-zero exit code when there are any changes made by applying rector rules. But you would also like to be able to cache the rector cache, so following runs can be executed faster / consume less resources. Currently however, it seems that using--dry-run
writes only very little to the cache (almost nothing) when compared to running without. Therefore, the caching in the CI does not work as expected..Here is a workaround I came up with:
vendor/bin/rector process
which fully populates the rector cache (if it is not already there from the cache restore)git reset --hard
vendor/bin/rector process --dry-run
which will use the cache from step 2, so it will be fast, but it will also exit with non-zero code if any changes are detected, which is what will make the pipeline fail (which is what we want)Diff
The text was updated successfully, but these errors were encountered: