mirror of
https://github.com/WordPress/WordPress-Coding-Standards.git
synced 2025-08-30 03:11:24 +08:00
Page:
Running in Travis
Pages
Customizable sniff properties
Escaping a WP_Error object
Fixing errors for input data
Home
How to use WordPressCS with Eclipse and XAMPP
Ignoring Parts of a File
Project Timeline
Running in GitHub Actions
Running in Travis
Sanitizing array input data
Setting up WordPressCS to work in Atom
Setting up WordPressCS to work in Sublime Text
Upgrade Guide to WordPressCS 2.0.0 for Developers of external standards
Upgrade Guide to WordPressCS 3.0.0 for Developers of external standards
Upgrade Guide to WordPressCS 3.0.0 for ruleset maintainers
No results
2
Running in Travis
jrfnl edited this page 2023-08-20 04:48:32 +02:00
Table of Contents
You can run PHPCS automatically whenever a new commit is pushed to your repository using Travis CI, just follow these steps.
Provided that:
- You are installing WordPressCS using Composer and can run it locally using
vendor/bin/phpcs
. - ... and you have a
[.]phpcs.xml[.dist]
file in your project root directory. (If not, add--standard=path/to/yourrulesetfile.xml
to the PHPCS command below). - Create the file
.travis.yml
and add the below yaml script to it.
Note: If you use a matrix setup in Travis to test your code against different PHP and/or WordPress versions, you don't need to run PHPCS on each variant of the matrix as the results will be same. You can set an environment variable in the Travis matrix to only run the sniffs against one setup in the matrix.
Travis CI example
language: php
jobs:
include:
# Arbitrary PHP version to run the sniffs against.
- php: 8.1
env: SNIFF=1
cache:
directories:
- $HOME/.composer/cache
before_install:
# Turn off Xdebug for performance reasons.
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
install:
# Install WordPressCS via Composer.
- if [[ "$SNIFF" == "1" ]]; then travis_retry composer install --no-interaction; fi
- if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi
script:
# Run against WordPress Coding Standards.
# You can use any of the normal PHPCS command line arguments in the command:
# https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage
- if [[ "$SNIFF" == "1" ]]; then vendor/bin/phpcs -p . --standard=WordPress; fi
IDE configuration
Fixing violations
Ignoring violations
Running in CI
For ruleset maintainers
For developers
Project History