diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index fdb7bdb..7af27d1 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -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 diff --git a/rector.php b/rector.php index 5c456ad..b4ec593 100644 --- a/rector.php +++ b/rector.php @@ -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; @@ -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/', diff --git a/src/Template/.github/workflows/rector.yml b/src/Template/.github/workflows/rector.yml index 60d159d..8040769 100644 --- a/src/Template/.github/workflows/rector.yml +++ b/src/Template/.github/workflows/rector.yml @@ -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 diff --git a/src/Template/rector.php b/src/Template/rector.php index 62e0146..d67af9d 100644 --- a/src/Template/rector.php +++ b/src/Template/rector.php @@ -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; @@ -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/',