Skip to content

Commit

Permalink
Merge pull request #128 from samsonasik/add-rector-cache
Browse files Browse the repository at this point in the history
chore: Add rector cache to workflows and template rector.php
  • Loading branch information
samsonasik authored Mar 24, 2024
2 parents 4bb7894 + 6d890ed commit 9588627
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,14 @@ jobs:
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
fi
- name: Rector Cache
uses: actions/cache@v4
with:
path: /tmp/rector
key: ${{ runner.os }}-rector-${{ github.run_id }}
restore-keys: ${{ runner.os }}-rector-

- run: mkdir -p /tmp/rector

- name: Analyze for refactoring
run: vendor/bin/rector process --dry-run --no-progress-bar
7 changes: 7 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
Expand Down Expand Up @@ -50,6 +51,12 @@

$rectorConfig->parallel();

// Github action cache
$rectorConfig->cacheClass(FileCacheStorage::class);
if (is_dir('/tmp')) {
$rectorConfig->cacheDirectory('/tmp/rector');
}

// The paths to refactor (can also be supplied with CLI arguments)
$rectorConfig->paths([
__DIR__ . '/src/',
Expand Down
9 changes: 9 additions & 0 deletions src/Template/.github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,14 @@ jobs:
composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
fi
- name: Rector Cache
uses: actions/cache@v4
with:
path: /tmp/rector
key: ${{ runner.os }}-rector-${{ github.run_id }}
restore-keys: ${{ runner.os }}-rector-

- run: mkdir -p /tmp/rector

- name: Analyze for refactoring
run: vendor/bin/rector process --dry-run --no-progress-bar
7 changes: 7 additions & 0 deletions src/Template/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
Expand Down Expand Up @@ -50,6 +51,12 @@

$rectorConfig->parallel();

// Github action cache
$rectorConfig->cacheClass(FileCacheStorage::class);
if (is_dir('/tmp')) {
$rectorConfig->cacheDirectory('/tmp/rector');
}

// The paths to refactor (can also be supplied with CLI arguments)
$rectorConfig->paths([
__DIR__ . '/app/',
Expand Down

0 comments on commit 9588627

Please sign in to comment.