Skip to content

Commit b6e744a

Browse files
committed
[cache] Make --dry-run work with disabled parallelization + add e2e test
1 parent 4182795 commit b6e744a

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

.github/workflows/e2e_consecutive_changes.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
php_version: ['8.1']
25+
rector_disable_parallel: ['true', 'false']
2526
directory:
2627
- 'e2e/consecutive-changes-with-cache'
2728

@@ -47,16 +48,24 @@ jobs:
4748
- run: php ../e2eTestChangingRunnerWithCache.php -o expected-output-1-dry-run.diff --dry-run
4849
working-directory: ${{ matrix.directory }}
4950
continue-on-error: true
51+
env:
52+
RECTOR_DISABLE_PARALLEL: ${{ matrix.rector_disable_parallel }}
5053

5154
# run e2e test with dry run once more, we expect non-zero exit code again
5255
- run: php ../e2eTestChangingRunnerWithCache.php -o expected-output-2-dry-run.diff --dry-run
5356
working-directory: ${{ matrix.directory }}
5457
continue-on-error: true
58+
env:
59+
RECTOR_DISABLE_PARALLEL: ${{ matrix.rector_disable_parallel }}
5560

5661
# run e2e test
5762
- run: php ../e2eTestChangingRunnerWithCache.php -o expected-output-3.diff
5863
working-directory: ${{ matrix.directory }}
64+
env:
65+
RECTOR_DISABLE_PARALLEL: ${{ matrix.rector_disable_parallel }}
5966

6067
# this tests that a 2nd run with cache and consecutive changes works, see https://github.com/rectorphp/rector-src/pull/3614#issuecomment-1507742338
6168
- run: php ../e2eTestChangingRunnerWithCache.php -o expected-output-4.diff
6269
working-directory: ${{ matrix.directory }}
70+
env:
71+
RECTOR_DISABLE_PARALLEL: ${{ matrix.rector_disable_parallel }}

e2e/consecutive-changes-with-cache/rector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
return static function (RectorConfig $rectorConfig): void {
1111
$rectorConfig->cacheClass(FileCacheStorage::class);
1212

13+
if (getenv('RECTOR_DISABLE_PARALLEL') === 'true') {
14+
$rectorConfig->disableParallel();
15+
}
16+
1317
$rectorConfig->paths([
1418
__DIR__ . '/src',
1519
]);

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ parameters:
5757

5858
ignoreErrors:
5959
- '#Cognitive complexity for "Rector\\Parallel\\WorkerRunner\:\:run\(\)" is 12, keep it under 11#'
60+
- '#Cognitive complexity for "Rector\\Core\\Application\\ApplicationFileProcessor\:\:processFiles\(\)" is 13, keep it under 11#'
6061
- '#Cognitive complexity for "Rector\\Php80\\NodeResolver\\SwitchExprsResolver\:\:resolve\(\)" is (.*?), keep it under 11#'
6162

6263
-

src/Application/ApplicationFileProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function processFiles(array $files, Configuration $configuration): array
133133

134134
if ($systemErrorsAndFileDiffs[Bridge::SYSTEM_ERRORS] !== []) {
135135
$this->changedFilesDetector->invalidateFile($file->getFilePath());
136-
} elseif (! $configuration->isDryRun()) {
136+
} else if (! $configuration->isDryRun() || $systemErrorsAndFileDiffs[Bridge::FILE_DIFFS] === []) {
137137
$this->changedFilesDetector->cacheFileWithDependencies($file->getFilePath());
138138
}
139139

0 commit comments

Comments
 (0)