-
Notifications
You must be signed in to change notification settings - Fork 27
How to?
While using custom coding standards, ensure that the vendor directory is present when the PHPCS action is running. If not, it needs to be installed in the workflow run. Also, the path for PHPCS in action needs to be updated.
For example, if you need woocommerce-sniffs coding standards in your repository. Run composer require woocommerce/woocommerce-sniffs
, this will generate the necessary composer.json
and composer.lock
files. You can also add more coding standards as per project requirements via composer.
Ideally, here is how your workflow file should look like when using custom coding standards:
on: pull_request
name: Inspections
jobs:
runPHPCSInspection:
name: Run PHPCS inspection
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
# Setup PHP with the required version and add extensions if needed any for composer install.
# Ref: https://github.com/shivammathur/setup-php#heavy_plus_sign-php-extension-support
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none
tools: composer
# Install composer dependencies in the workflow run.
- name: Composer install
run: composer install --no-dev --no-progress --no-interaction
- name: Run PHPCS inspection
uses: rtCamp/action-phpcs-code-review@master
env:
GH_BOT_TOKEN: ${{ secrets.RTBOT_TOKEN }}
# Add the phpcs path to pickup custom coding standard
# Ref: https://github.com/rtCamp/action-phpcs-code-review/#custom-coding-standards
PHPCS_FILE_PATH: vendor/bin/phpcs
Also, along with this, add .vipgoci_phpcs_skip_folders
file with .github
, vendor
and other directories inside it for properly skipping them during the workflow run. Ref: https://github.com/rtCamp/action-phpcs-code-review/#skipping-phpcs-scanning-for-specific-folders. Do not use the env variable SKIP_FOLDERS
for custom coding standard based setup.