Skip to content

Commit f82dc32

Browse files
authored
Merge pull request #8655 from samsonasik/rector-cache
chore: Enable rector cache
2 parents da4861c + eebfaa4 commit f82dc32

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

.github/workflows/test-rector.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,12 @@ permissions:
4040

4141
jobs:
4242
build:
43-
name: PHP ${{ matrix.php-versions }} Analyze code (Rector) on ${{ matrix.paths }}
43+
name: PHP ${{ matrix.php-versions }} Analyze code (Rector)
4444
runs-on: ubuntu-22.04
4545
strategy:
4646
fail-fast: false
4747
matrix:
4848
php-versions: ['7.4', '8.0']
49-
paths:
50-
- app
51-
- system
52-
- tests
53-
- utils
5449
steps:
5550
- name: Checkout
5651
uses: actions/checkout@v4
@@ -80,5 +75,14 @@ jobs:
8075
- name: Install dependencies
8176
run: composer update --ansi --no-interaction
8277

78+
- name: Rector Cache
79+
uses: actions/cache@v4
80+
with:
81+
path: /tmp/rector
82+
key: ${{ runner.os }}-rector-${{ github.run_id }}
83+
restore-keys: ${{ runner.os }}-rector-
84+
85+
- run: mkdir -p /tmp/rector
86+
8387
- name: Run static analysis
84-
run: vendor/bin/rector process ${{ matrix.paths }} --dry-run --no-progress-bar
88+
run: vendor/bin/rector process --dry-run --no-progress-bar

rector.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* the LICENSE file that was distributed with this source code.
1010
*/
1111

12+
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
1213
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
1314
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
1415
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
@@ -62,6 +63,12 @@
6263

6364
$rectorConfig->parallel(120, 8, 10);
6465

66+
// Github action cache
67+
$rectorConfig->cacheClass(FileCacheStorage::class);
68+
if (is_dir('/tmp')) {
69+
$rectorConfig->cacheDirectory('/tmp/rector');
70+
}
71+
6572
// paths to refactor; solid alternative to CLI arguments
6673
$rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']);
6774

0 commit comments

Comments
 (0)