From 0286a0becbfab220eb07aae080114eb1ffbcdede Mon Sep 17 00:00:00 2001 From: Aaron Ware Date: Wed, 9 Feb 2022 16:37:56 -0500 Subject: [PATCH] improve: Improve workflows for coding standards --- .github/workflows/phpcbf.yml | 94 +++++++++++++++++++---------------- .github/workflows/phpcs.yml | 28 +++++++++++ .github/workflows/phplint.yml | 36 ++++++++++++++ 3 files changed, 114 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/phpcs.yml create mode 100644 .github/workflows/phplint.yml diff --git a/.github/workflows/phpcbf.yml b/.github/workflows/phpcbf.yml index d87b44b1..191e102f 100644 --- a/.github/workflows/phpcbf.yml +++ b/.github/workflows/phpcbf.yml @@ -1,51 +1,57 @@ -name: WordPress PHPCS Coding Standards Autofixer - on: - pull_request: - paths: - - '**.php' + pull_request: + branches-ignore: + # Do not run on auto submitted branches + - '**-phpcbf' + - 'dependabot/' + - 'renovate/' + paths: + - '**.php' + +name: WordPress Autofixer jobs: - phpcbf-fixer: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} + phpcbf-fixer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - coverage: none - tools: cs2pr + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: none + tools: cs2pr - # Install dependencies and handle caching in one go. - # @link https://github.com/marketplace/actions/install-composer-dependencies - - name: Install Composer dependencies - uses: "ramsey/composer-install@v1" + # Install dependencies and handle caching in one go. + # @link https://github.com/marketplace/actions/install-composer-dependencies + - name: Install Composer dependencies + uses: "ramsey/composer-install@v1" - # Check the code-style consistency of the PHP files. - - name: Fix PHP code style - continue-on-error: true - run: ./vendor/squizlabs/php_codesniffer/bin/phpcbf -p -v --standard=${{ github.workspace }}/phpcs.xml --extensions=php ${{ github.workspace }}/ + # Check the code-style consistency of the PHP files. + - name: Fix PHP code style + id: codestyle + continue-on-error: true + run: ./vendor/squizlabs/php_codesniffer/bin/phpcbf . --standard=${{ github.workspace }}/phpcs.xml - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v3 - with: - token: ${{ secrets.GH_BOT_TOKEN }} - commit-message: PHPCBF Auto Fix - committer: Linchpin Bot - author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> - signoff: false - branch: ${{ github.event.pull_request.head.ref }}-phpcbf - delete-branch: true - title: 'Auto Fix Formatting' - body: | - Update Formatting - labels: | - phpcs - automated pr - milestone: 1 - draft: false + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GH_BOT_TOKEN }} + commit-message: PHPCBF Auto Fix + committer: Linchpin Bot + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + signoff: false + branch: ${{ github.event.pull_request.head.ref }}-phpcbf + delete-branch: true + title: 'Auto Fix Formatting' + body: | + Update Formatting + labels: | + phpcs + automated pr + milestone: 1 + draft: false diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 00000000..dd17192e --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,28 @@ +on: + pull_request: + branches-ignore: + # Do not run on auto submitted branches + - '**-phpcbf' + - 'dependabot/' + - 'renovate/' + paths: + - '**.php' + +name: WordPress Coding Standards Inspections + +jobs: + runPHPCSInspection: + name: Run PHPCS inspection + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Run PHPCS inspection + uses: rtCamp/action-phpcs-code-review@v2.1.0 + env: + GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} + SKIP_FOLDERS: ".deployment,.github,assets,css,js,lib,sourcedata,wsdl,vendor" + PHPCS_STANDARD_FILE_NAME: "phpcs.xml" + with: + args: "WordPress,WordPress-Core,WordPress-Extra" diff --git a/.github/workflows/phplint.yml b/.github/workflows/phplint.yml new file mode 100644 index 00000000..ecdc81ae --- /dev/null +++ b/.github/workflows/phplint.yml @@ -0,0 +1,36 @@ +on: + pull_request: + branches-ignore: + # Do not run on auto submitted branches + - '**-phpcbf' + - 'dependabot/' + - 'renovate/' + paths: + - '**.php' + +name: PHP Lint + +jobs: + php-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: none + tools: cs2pr + + # Install dependencies and handle caching in one go. + # @link https://github.com/marketplace/actions/install-composer-dependencies + - name: Install Composer dependencies + uses: "ramsey/composer-install@v2" + + - name: PHP Lint + uses: overtrue/phplint@8.0 + with: + path: .