diff --git a/.github/workflows/test-rector.yml b/.github/workflows/test-rector.yml index 9d9e402ff035..bb03e62ed161 100644 --- a/.github/workflows/test-rector.yml +++ b/.github/workflows/test-rector.yml @@ -40,17 +40,12 @@ permissions: jobs: build: - name: PHP ${{ matrix.php-versions }} Analyze code (Rector) on ${{ matrix.paths }} + name: PHP ${{ matrix.php-versions }} Analyze code (Rector) runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: php-versions: ['7.4', '8.0'] - paths: - - app - - system - - tests - - utils steps: - name: Checkout uses: actions/checkout@v4 @@ -80,5 +75,14 @@ jobs: - name: Install dependencies run: composer update --ansi --no-interaction + - 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: Run static analysis - run: vendor/bin/rector process ${{ matrix.paths }} --dry-run --no-progress-bar + run: vendor/bin/rector process --dry-run --no-progress-bar diff --git a/rector.php b/rector.php index 5e19e8e01413..321bf3930b06 100644 --- a/rector.php +++ b/rector.php @@ -9,6 +9,7 @@ * the LICENSE file that was distributed with this source code. */ +use Rector\Caching\ValueObject\Storage\FileCacheStorage; use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; @@ -62,6 +63,12 @@ $rectorConfig->parallel(120, 8, 10); + // Github action cache + $rectorConfig->cacheClass(FileCacheStorage::class); + if (is_dir('/tmp')) { + $rectorConfig->cacheDirectory('/tmp/rector'); + } + // paths to refactor; solid alternative to CLI arguments $rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']);