Skip to content

Commit

Permalink
improve: Improve workflows for coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronware committed Feb 9, 2022
1 parent c1eae3f commit 0286a0b
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 44 deletions.
94 changes: 50 additions & 44 deletions .github/workflows/phpcbf.yml
Original file line number Diff line number Diff line change
@@ -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 <dev@linchpin.com>
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 <dev@linchpin.com>
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
28 changes: 28 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -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"
36 changes: 36 additions & 0 deletions .github/workflows/phplint.yml
Original file line number Diff line number Diff line change
@@ -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: .

0 comments on commit 0286a0b

Please # to comment.