From b4b0bd0170f4ffbe750d7e6428ddee7cfd307192 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Thu, 26 Jun 2025 21:53:39 +0700 Subject: [PATCH] Refactor workflows --- .github/workflows/build.yml | 17 ++---- .../workflows/composer-require-checker.yml | 53 +++--------------- .github/workflows/mutation.yml | 12 ++--- .github/workflows/rector.yml | 12 +++-- .github/workflows/static.yml | 54 +++---------------- rector.php | 33 ++++-------- 6 files changed, 40 insertions(+), 141 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 55e755dcc..6cb5d2fee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,22 +59,11 @@ jobs: - name: Update composer. run: composer self-update - - name: Set environment variables pull request linux. - if: matrix.os == 'ubuntu-latest' - uses: yiisoft/actions/db/environment-linux@master - - - name: Set environment variables pull request windows. - if: matrix.os == 'windows-latest' - uses: yiisoft/actions/db/environment-windows@master - - name: Install db. - uses: yiisoft/actions/db/subpackage-install@master + uses: yiisoft/actions/install-packages@master with: - BRANCH_NAME: ${{ env.BRANCH_NAME }} - COMPOSER_ROOT_VERSION: ${{ env.COMPOSER_ROOT_VERSION }} - CURRENT_PACKAGE: db - FULL_BRANCH_NAME: ${{ env.FULL_BRANCH_NAME }} - WORK_PACKAGE_URL: ${{ env.WORK_PACKAGE_URL }} + packages: >- + ['db'] - name: Run tests with phpunit with code coverage. run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always --display-warnings --display-deprecations diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 07d5e7a62..1face1f24 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -4,6 +4,7 @@ on: - 'src/**' - '.github/workflows/composer-require-checker.yml' - 'composer.json' + - 'composer-require-checker.json' push: branches: ['master'] @@ -11,6 +12,7 @@ on: - 'src/**' - '.github/workflows/composer-require-checker.yml' - 'composer.json' + - 'composer-require-checker.json' name: Composer require checker @@ -20,48 +22,9 @@ concurrency: jobs: composer-require-checker: - name: PHP ${{ matrix.php }} - - env: - COMPOSER_ROOT_VERSION: 1.0.0 - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: - - ubuntu-latest - - php: - - 8.1 - - 8.2 - - 8.3 - - 8.4 - - steps: - - name: Checkout. - uses: actions/checkout@v4 - - - name: Install PHP with extensions. - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - - - name: Update composer. - run: composer self-update - - - name: Set environment variables pull request linux. - uses: yiisoft/actions/db/environment-linux@master - - - name: Install db. - uses: yiisoft/actions/db/subpackage-install@master - with: - BRANCH_NAME: ${{ env.BRANCH_NAME }} - COMPOSER_ROOT_VERSION: ${{ env.COMPOSER_ROOT_VERSION }} - CURRENT_PACKAGE: db - FULL_BRANCH_NAME: ${{ env.FULL_BRANCH_NAME }} - WORK_PACKAGE_URL: ${{ env.WORK_PACKAGE_URL }} - - - name: Check dependencies. - run: vendor/bin/composer-require-checker + uses: yiisoft/actions/.github/workflows/composer-require-checker.yml@master + with: + php: >- + ['8.1', '8.2', '8.3', '8.4'] + required-packages: >- + ['db'] diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index 88d35df50..b00f96300 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -51,17 +51,11 @@ jobs: - name: Update composer. run: composer self-update - - name: Set environment variables pull request linux. - uses: yiisoft/actions/db/environment-linux@master - - name: Install db. - uses: yiisoft/actions/db/subpackage-install@master + uses: yiisoft/actions/install-packages@master with: - BRANCH_NAME: ${{ env.BRANCH_NAME }} - COMPOSER_ROOT_VERSION: ${{ env.COMPOSER_ROOT_VERSION }} - CURRENT_PACKAGE: db - FULL_BRANCH_NAME: ${{ env.FULL_BRANCH_NAME }} - WORK_PACKAGE_URL: ${{ env.WORK_PACKAGE_URL }} + packages: >- + ['db'] - name: Run infection. run: | diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 4f2528500..e4f3f8f80 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -1,12 +1,13 @@ on: - pull_request: + pull_request_target: paths: - 'src/**' + - 'tests/**' - '.github/workflows/rector.yml' - 'composer.json' - 'rector.php' -name: rector +name: Rector concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -15,8 +16,11 @@ concurrency: jobs: rector: uses: yiisoft/actions/.github/workflows/rector.yml@master + secrets: + token: ${{ secrets.YIISOFT_GITHUB_TOKEN }} with: - os: >- - ['ubuntu-latest'] + repository: ${{ github.event.pull_request.head.repo.full_name }} php: >- ['8.4'] + required-packages: >- + ['db'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index f96cd64a5..287f4ac96 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -14,7 +14,7 @@ on: - 'psalm*.xml' - 'composer.json' -name: static analysis +name: Static analysis concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -22,49 +22,9 @@ concurrency: jobs: psalm: - name: PHP ${{ matrix.php }} - - env: - COMPOSER_ROOT_VERSION: 1.0.0 - - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: - - ubuntu-latest - - php: - - 8.1 - - 8.2 - - 8.3 - - 8.4 - - steps: - - name: Checkout. - uses: actions/checkout@v4 - - - name: Install PHP with extensions. - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - tools: cs2pr - - - name: Update composer. - run: composer self-update - - - name: Set environment variables pull request linux. - uses: yiisoft/actions/db/environment-linux@master - - - name: Install db. - uses: yiisoft/actions/db/subpackage-install@master - with: - BRANCH_NAME: ${{ env.BRANCH_NAME }} - COMPOSER_ROOT_VERSION: ${{ env.COMPOSER_ROOT_VERSION }} - CURRENT_PACKAGE: db - FULL_BRANCH_NAME: ${{ env.FULL_BRANCH_NAME }} - WORK_PACKAGE_URL: ${{ env.WORK_PACKAGE_URL }} - - - name: Static analysis. - run: vendor/bin/psalm --config=${{ inputs.psalm-config }} --shepherd --stats --output-format=github --php-version=${{ matrix.php }} + uses: yiisoft/actions/.github/workflows/psalm.yml@master + with: + php: >- + ['8.1', '8.2', '8.3', '8.4'] + required-packages: >- + ['db'] diff --git a/rector.php b/rector.php index 026867b39..8867f26bd 100644 --- a/rector.php +++ b/rector.php @@ -6,29 +6,18 @@ use Rector\Config\RectorConfig; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; -use Rector\Set\ValueObject\LevelSetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->disableParallel(); - - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__ . '/src', - /** - * Disabled ./tests directory due to different branches with main package when testing - */ - // __DIR__ . '/tests', - ]); - - // register a single rule - $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); - - // define sets of rules - $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_81, - ]); - - $rectorConfig->skip([ + __DIR__ . '/tests', + ]) + ->withPhpSets(php81: true) + ->withRules([ + InlineConstructorDefaultToPropertyRector::class, + ]) + ->withSkip([ NullToStrictStringFuncCallArgRector::class, ReadOnlyPropertyRector::class, - ]); -}; + ]) + ->withoutParallel();