Skip to content

GitHub Action to help you lint your PHP without additional dependencies within your codebase

License

Notifications You must be signed in to change notification settings

10up/wpcs-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPCS GitHub Action

GitHub Action to help you lint your PHP without additional dependencies within your codebase

Support Level Release Version MIT License

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.

Known Caveats/Issues

Annotations limit

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.

Usage

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@master

Available options (with default value):

        ...
        - name: WPCS check
          uses: 10up/wpcs-action@master
          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
            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

Examples

VIP Coding Standards

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@master
          with:
            standard: 'WordPress-VIP-Go'

Support Level

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.

Like what you see?

About

GitHub Action to help you lint your PHP without additional dependencies within your codebase

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages

  • Shell 97.1%
  • Dockerfile 2.9%