From cfb0e35454a45aa51dfcd7d32ba638bc679686f2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Mar 2024 01:49:05 +0700 Subject: [PATCH 1/9] chore: Enable rector cache --- .github/workflows/test-rector.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test-rector.yml b/.github/workflows/test-rector.yml index 9d9e402ff035..80874ff27267 100644 --- a/.github/workflows/test-rector.yml +++ b/.github/workflows/test-rector.yml @@ -80,5 +80,14 @@ jobs: - name: Install dependencies run: composer update --ansi --no-interaction + - name: Rector Cache + uses: actions/cache@v4 + with: + path: /tmp/rector-${{ matrix.paths }} + key: ${{ runner.os }}-rector-${{ github.run_id }}-${{ matrix.paths }} + restore-keys: ${{ runner.os }}-rector-${{ matrix.paths }} + + - run: mkdir -p /tmp/rector-${{ matrix.paths }} + - name: Run static analysis run: vendor/bin/rector process ${{ matrix.paths }} --dry-run --no-progress-bar From 4a5b55622d590dda6d458165dfe97172984b54a9 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Mar 2024 01:53:18 +0700 Subject: [PATCH 2/9] test commit to verify cache read From f304d9504830eabae9525f6cd2b9a6b9e39ae34d Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Mar 2024 02:06:21 +0700 Subject: [PATCH 3/9] set cache directory --- rector.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rector.php b/rector.php index 5e19e8e01413..5c0758ffb342 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,16 @@ $rectorConfig->parallel(120, 8, 10); + // Github action cache + $rectorConfig->cacheClass(FileCacheStorage::class); + + if (isset($_SERVER['argv'][2]) + && in_array($_SERVER['argv'][2], ['app', 'system', 'tests', 'utils'], true) + && is_dir('/tmp/rector-' . $_SERVER['argv'][2]) + ) { + $rectorConfig->cacheDirectory($_SERVER['argv'][2]); + } + // paths to refactor; solid alternative to CLI arguments $rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']); From 5b2bf1399bd1eb2ecaeea097eefa35ef28bc38d2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Mar 2024 02:06:38 +0700 Subject: [PATCH 4/9] set cache directory --- rector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 5c0758ffb342..e913b1133eb9 100644 --- a/rector.php +++ b/rector.php @@ -70,7 +70,7 @@ && in_array($_SERVER['argv'][2], ['app', 'system', 'tests', 'utils'], true) && is_dir('/tmp/rector-' . $_SERVER['argv'][2]) ) { - $rectorConfig->cacheDirectory($_SERVER['argv'][2]); + $rectorConfig->cacheDirectory('/tmp/rector-' . $_SERVER['argv'][2]); } // paths to refactor; solid alternative to CLI arguments From faad1fc06e460dfc2474e53a08c12c7391fac57e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Mar 2024 02:08:04 +0700 Subject: [PATCH 5/9] update key cache --- .github/workflows/test-rector.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-rector.yml b/.github/workflows/test-rector.yml index 80874ff27267..a26a0f6b40e6 100644 --- a/.github/workflows/test-rector.yml +++ b/.github/workflows/test-rector.yml @@ -84,7 +84,7 @@ jobs: uses: actions/cache@v4 with: path: /tmp/rector-${{ matrix.paths }} - key: ${{ runner.os }}-rector-${{ github.run_id }}-${{ matrix.paths }} + key: ${{ runner.os }}-rector-${{ matrix.paths }}-${{ github.run_id }} restore-keys: ${{ runner.os }}-rector-${{ matrix.paths }} - run: mkdir -p /tmp/rector-${{ matrix.paths }} From 178c40383b32cec0a19b81fee86b9cc64d550a15 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Mar 2024 02:10:05 +0700 Subject: [PATCH 6/9] update restore key cache --- .github/workflows/test-rector.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-rector.yml b/.github/workflows/test-rector.yml index a26a0f6b40e6..8c4aaf3995c4 100644 --- a/.github/workflows/test-rector.yml +++ b/.github/workflows/test-rector.yml @@ -85,7 +85,7 @@ jobs: with: path: /tmp/rector-${{ matrix.paths }} key: ${{ runner.os }}-rector-${{ matrix.paths }}-${{ github.run_id }} - restore-keys: ${{ runner.os }}-rector-${{ matrix.paths }} + restore-keys: ${{ runner.os }}-rector-${{ matrix.paths }}- - run: mkdir -p /tmp/rector-${{ matrix.paths }} From 2192356238028793cf4b0e5ed5a9b161fd46e477 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Mar 2024 02:14:06 +0700 Subject: [PATCH 7/9] trigger From ec54a6b207e0adfb3cadc23725f2df06c00314b5 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Mar 2024 02:24:02 +0700 Subject: [PATCH 8/9] combine paths --- .github/workflows/test-rector.yml | 17 ++++++----------- rector.php | 8 ++------ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test-rector.yml b/.github/workflows/test-rector.yml index 8c4aaf3995c4..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 @@ -83,11 +78,11 @@ jobs: - name: Rector Cache uses: actions/cache@v4 with: - path: /tmp/rector-${{ matrix.paths }} - key: ${{ runner.os }}-rector-${{ matrix.paths }}-${{ github.run_id }} - restore-keys: ${{ runner.os }}-rector-${{ matrix.paths }}- + path: /tmp/rector + key: ${{ runner.os }}-rector-${{ github.run_id }} + restore-keys: ${{ runner.os }}-rector- - - run: mkdir -p /tmp/rector-${{ matrix.paths }} + - 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 e913b1133eb9..321bf3930b06 100644 --- a/rector.php +++ b/rector.php @@ -65,12 +65,8 @@ // Github action cache $rectorConfig->cacheClass(FileCacheStorage::class); - - if (isset($_SERVER['argv'][2]) - && in_array($_SERVER['argv'][2], ['app', 'system', 'tests', 'utils'], true) - && is_dir('/tmp/rector-' . $_SERVER['argv'][2]) - ) { - $rectorConfig->cacheDirectory('/tmp/rector-' . $_SERVER['argv'][2]); + if (is_dir('/tmp')) { + $rectorConfig->cacheDirectory('/tmp/rector'); } // paths to refactor; solid alternative to CLI arguments From eebfaa459429faed455d50fb8b63234a30dd16d2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 24 Mar 2024 02:28:10 +0700 Subject: [PATCH 9/9] read rector cache