From ecafdb6ec375f5013a16a6249203d38495590b25 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Thu, 6 Oct 2022 15:39:15 -0300 Subject: [PATCH] Agregar rector-ci. --- .github/workflows/config/rector-config.php | 22 +++++++ .github/workflows/rector.yml | 68 ++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 .github/workflows/config/rector-config.php create mode 100644 .github/workflows/rector.yml diff --git a/.github/workflows/config/rector-config.php b/.github/workflows/config/rector-config.php new file mode 100644 index 0000000..63713ce --- /dev/null +++ b/.github/workflows/config/rector-config.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, + ]); +}; diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml new file mode 100644 index 0000000..f8ea80c --- /dev/null +++ b/.github/workflows/rector.yml @@ -0,0 +1,68 @@ +name: rector + +on: + workflow_call: + inputs: + os: + description: Os to test, separated by comma. + required: true + type: string + php: + description: PHP versions to test, separated by comma. + required: true + type: string + +jobs: + rector: + name: PHP ${{ matrix.php }}-${{ matrix.os }} + + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: ${{ fromJson(inputs.os) }} + php: ${{ fromJson(inputs.php) }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + 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@v3 + 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 --config=$GITHUB_ACTION_PATH/config/rector-config.php + + - 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) + + - uses: EndBug/add-and-commit@v7.5.0 + with: + add: . + message: "[ci-review] Apply changes from Rector action." + author_name: "rector-bot" + author_email: "rector@yiiframework.com" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}