From f9d3f7a750fe670bef122aa77586d708add71bde Mon Sep 17 00:00:00 2001 From: Tigrov Date: Thu, 26 Jun 2025 22:13:51 +0700 Subject: [PATCH] Refactor workflows --- .github/workflows/build.yml | 12 ++--- .../workflows/composer-require-checker.yml | 53 +++--------------- .github/workflows/mutation.yml | 12 ++--- .github/workflows/rector.yml | 12 +++-- .github/workflows/static.yml | 54 +++---------------- rector.php | 28 ++++------ 6 files changed, 38 insertions(+), 133 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c389fb1..acf4efc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,17 +82,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 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 07d5e7a..1face1f 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 f20a011..5f2fd11 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -66,17 +66,11 @@ jobs: ini-values: memory_limit=-1 coverage: pcov - - 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 4f25285..e4f3f8f 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 f96cd64..287f4ac 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 83a3a47..0d67fe5 100644 --- a/rector.php +++ b/rector.php @@ -8,29 +8,19 @@ use Rector\Php73\Rector\String_\SensitiveHereNowDocRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; -use Rector\Set\ValueObject\LevelSetList; -return static function (RectorConfig $rectorConfig): void { - $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, SensitiveHereNowDocRector::class, RemoveParentCallWithoutParentRector::class, ]); -};