From 42c5e3174c02a80a83305f29542c037a6d11cf63 Mon Sep 17 00:00:00 2001 From: Dmitrii Derepko Date: Tue, 27 Sep 2022 16:20:26 +0300 Subject: [PATCH] Add rector files https://github.com/yiisoft/yii-dev-tool/pull/232 --- .github/workflows/rector.yml | 65 ++++++++++++++++++++++++++++++++++++ rector.php | 22 ++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 .github/workflows/rector.yml create mode 100644 rector.php diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml new file mode 100644 index 0000000..b235fb0 --- /dev/null +++ b/.github/workflows/rector.yml @@ -0,0 +1,65 @@ +on: + push: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.env.example' + - '.gitattributes' + - 'infection.json.dist' + - 'phpunit.xml.dist' + +name: rector + +jobs: + rector: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + tools: composer:v2 + coverage: none + + - name: Determine composer cache directory + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV + + - name: Cache dependencies installed with composer + uses: actions/cache@v2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + php${{ matrix.php }}-composer- + + - name: Update composer + run: composer self-update + + - name: Install dependencies with composer + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - run: vendor/bin/rector process --ansi + + - name: Check for Rector modified files + id: rector-git-check + run: echo ::set-output name=modified::$(if git diff --exit-code --no-patch; then echo "false"; else echo "true"; fi) + + - name: Git config + if: steps.rector-git-check.outputs.modified == 'true' + run: | + git config --global user.name 'rector-bot' + git config --global user.email 'rector@yiiframework.com' + + - name: Commit Rector changes + if: steps.rector-git-check.outputs.modified == 'true' + run: git commit -am "[rector] Apply fixes" + + - name: Push changes + if: steps.rector-git-check.outputs.modified == 'true' + run: git push + diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..63713ce --- /dev/null +++ b/rector.php @@ -0,0 +1,22 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]); + + // register a single rule + $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); + + // define sets of rules + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_80, + ]); +};