GitHub Action to help you lint your PHP without additional dependencies within your codebase
This action will help you to run phpcs (PHP_CodeSniffer) against WordPress Coding Standards with GitHub Actions platform.
To make it as simple as possible, this action supports WordPress Coding Standards exclusively and only checks for PHP files. This action doesn't require any change or addition to your source code. It means that you don't need to add composer/phpcs to your plugin or create PHP CodeSniffer config to use this action.
This is a fork of chekalsky/phpcs-action, so this action supports GitHub Action annotations too. All credit goes to Ilya Chekalsky.
From v1.3.1, this action can detect the PHPCS custom config and use that config to check the source code. When using the local config, paths
, excludes
, and standard
are ignored.
☞ Check out our collection of WordPress-focused GitHub Actions
GitHub allows only 10 warning annotations and 10 error annotations per step. So any warning/error exceeds this threshold won't show on the GitHub Pull Request page.
Add the following code to .github/workflows/wpcs.yml
file.
name: WPCS check
on: pull_request
jobs:
phpcs:
name: WPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: WPCS check
uses: 10up/wpcs-action@stable
Available options (with default value):
...
- name: WPCS check
uses: 10up/wpcs-action@stable
with:
enable_warnings: false # Enable checking for warnings (-w)
paths: '.' # Paths to check, space separated
excludes: '' # Paths to excludes, space separated
standard: 'WordPress' # Standard to use. Accepts WordPress|WordPress-Core|WordPress-Docs|WordPress-Extra|WordPress-VIP-Go|WordPressVIPMinimum|10up-Default.
standard_repo: '' # Public (git) repository URL of the coding standard
repo_branch: 'master' # Branch of Standard repository
phpcs_bin_path: 'phpcs' # Custom PHPCS bin path
use_local_config: 'false' # Use local config if available
extra_args: '' # Extra arguments passing to the command
name: WPCS check
on: pull_request
jobs:
phpcs:
name: VIPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: VIPCS check
uses: 10up/wpcs-action@stable
with:
standard: 'WordPress-VIP-Go'
name: WPCS check
on: pull_request
jobs:
phpcs:
name: VIPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: VIPCS check
uses: 10up/wpcs-action@stable
with:
standard: 'WordPress-VIP-Go'
extra_args: '--report-json=./phpcs.json'
- name: Update summary
run: |
npx --yes github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md
cat phpcs.md >> $GITHUB_STEP_SUMMARY
if: always()
Active: 10up is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.