From 44862b5dafa7a4873d27747ab751db17d00ee042 Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 7 Jun 2024 20:13:55 +0300 Subject: [PATCH] ci: add rector refactoring workflow --- .github/CONTRIBUTING.md | 1 + .github/assets/.gitkeep | 0 .github/workflows/refactoring.yml | 65 +++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) delete mode 100644 .github/assets/.gitkeep create mode 100644 .github/workflows/refactoring.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a8ad0f81..cff462db 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -171,6 +171,7 @@ Our project employs [GitHub Actions](https://github.com/features/actions) for co | [`coding-standards.yml`](workflows/coding-standards.yml) | Checks `yaml`, `md`, `composer`, `php` and commit coding standards. | | [`create-release.yml`](workflows/create-release.yml) | Creates a release on GitHub. | | [`dependency-analysis.yml`](workflows/dependency-analysis.yml) | Checks for dependency issues. | +| [`refactoring.yml`](workflows/refactoring.yml) | Runs rector/rector code check. | | [`security-analysis.yml`](workflows/security-analysis.yml) | Checks for security issues. | | [`shellcheck.yml`](workflows/shellcheck.yml) | Checks shell scripts. | | [`static-analysis.yml`](workflows/static-analysis.yml) | Runs `psalm` and `phpstan` tools. | diff --git a/.github/assets/.gitkeep b/.github/assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/.github/workflows/refactoring.yml b/.github/workflows/refactoring.yml new file mode 100644 index 00000000..afaf8f11 --- /dev/null +++ b/.github/workflows/refactoring.yml @@ -0,0 +1,65 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + paths: + - 'src/**' + - 'tests/**' + - '.php-cs-fixer.dist.php' + - 'rector.php' + +name: ⚙️ Refactoring + +jobs: + refactoring: + timeout-minutes: 4 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: refactoring-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + php-version: + - '8.1' + dependencies: + - locked + steps: + - name: 📦 Check out the codebase + uses: actions/checkout@v4.1.6 + + - name: 🛠️ Setup PHP + uses: shivammathur/setup-php@2.30.5 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring + ini-values: error_reporting=E_ALL + coverage: none + + - name: 🛠️ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: 🤖 Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: 🔍 Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0 + + - name: ♻️ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: 📥 Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@v3.1.0 + with: + dependencies: ${{ matrix.dependencies }} + + - name: ⚙️ Run automated refactoring with rector/rector + run: composer refactor:ci