Skip to content

Commit 9588627

Browse files
authored
Merge pull request #128 from samsonasik/add-rector-cache
chore: Add rector cache to workflows and template rector.php
2 parents 4bb7894 + 6d890ed commit 9588627

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

.github/workflows/rector.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,14 @@ jobs:
6060
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
6161
fi
6262
63+
- name: Rector Cache
64+
uses: actions/cache@v4
65+
with:
66+
path: /tmp/rector
67+
key: ${{ runner.os }}-rector-${{ github.run_id }}
68+
restore-keys: ${{ runner.os }}-rector-
69+
70+
- run: mkdir -p /tmp/rector
71+
6372
- name: Analyze for refactoring
6473
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
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
56
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
67
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
78
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
@@ -50,6 +51,12 @@
5051

5152
$rectorConfig->parallel();
5253

54+
// Github action cache
55+
$rectorConfig->cacheClass(FileCacheStorage::class);
56+
if (is_dir('/tmp')) {
57+
$rectorConfig->cacheDirectory('/tmp/rector');
58+
}
59+
5360
// The paths to refactor (can also be supplied with CLI arguments)
5461
$rectorConfig->paths([
5562
__DIR__ . '/src/',

src/Template/.github/workflows/rector.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,14 @@ jobs:
6060
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
6161
fi
6262
63+
- name: Rector Cache
64+
uses: actions/cache@v4
65+
with:
66+
path: /tmp/rector
67+
key: ${{ runner.os }}-rector-${{ github.run_id }}
68+
restore-keys: ${{ runner.os }}-rector-
69+
70+
- run: mkdir -p /tmp/rector
71+
6372
- name: Analyze for refactoring
6473
run: vendor/bin/rector process --dry-run --no-progress-bar

src/Template/rector.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
56
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
67
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
78
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
@@ -50,6 +51,12 @@
5051

5152
$rectorConfig->parallel();
5253

54+
// Github action cache
55+
$rectorConfig->cacheClass(FileCacheStorage::class);
56+
if (is_dir('/tmp')) {
57+
$rectorConfig->cacheDirectory('/tmp/rector');
58+
}
59+
5360
// The paths to refactor (can also be supplied with CLI arguments)
5461
$rectorConfig->paths([
5562
__DIR__ . '/app/',

0 commit comments

Comments
 (0)