mirror of
https://gh.wpcy.net/https://github.com/WordPress/WordPress-Coding-Standards.git
synced 2026-04-27 01:12:39 +08:00
As per https://twitter.com/kelunik/status/954242454676475904 When newer images of PHP versions become available (or on the HHVM images for that matter), Xdebug isn't always installed. Using this little titbit, the builds won't break because of it.
107 lines
5.4 KiB
YAML
107 lines
5.4 KiB
YAML
sudo: false
|
|
|
|
dist: trusty
|
|
|
|
cache:
|
|
apt: true
|
|
|
|
language:
|
|
- php
|
|
|
|
php:
|
|
- 5.4
|
|
- 5.5
|
|
- 5.6
|
|
- 7.0
|
|
- 7.1
|
|
- 7.2
|
|
- nightly
|
|
|
|
env:
|
|
# `master` is now 3.x.
|
|
- PHPCS_BRANCH=master LINT=1
|
|
# Lowest tagged release in the 2.x series with which WPCS is compatible.
|
|
- PHPCS_BRANCH=2.9.0
|
|
|
|
matrix:
|
|
fast_finish: true
|
|
include:
|
|
# Run PHPCS against WPCS. I just picked to run it against 7.0.
|
|
- php: 7.0
|
|
env: PHPCS_BRANCH=master SNIFF=1
|
|
addons:
|
|
apt:
|
|
packages:
|
|
- libxml2-utils
|
|
|
|
# Run against HHVM.
|
|
- php: hhvm
|
|
sudo: required
|
|
dist: trusty
|
|
group: edge
|
|
env: PHPCS_BRANCH=master LINT=1
|
|
|
|
# Test PHP 5.3 only against PHPCS 2.x as PHPCS 3.x has a minimum requirement of PHP 5.4.
|
|
- php: 5.3
|
|
env: PHPCS_BRANCH=2.9 LINT=1
|
|
dist: precise
|
|
# Test PHP 5.3 with short_open_tags set to On (is Off by default)
|
|
- php: 5.3
|
|
env: PHPCS_BRANCH=2.9.0 SHORT_OPEN_TAGS=true
|
|
dist: precise
|
|
|
|
allow_failures:
|
|
# Allow failures for unstable builds.
|
|
- php: nightly
|
|
- php: hhvm
|
|
|
|
before_install:
|
|
# Speed up build time by disabling Xdebug.
|
|
# https://johnblackbourn.com/reducing-travis-ci-build-times-for-wordpress-projects/
|
|
# https://twitter.com/kelunik/status/954242454676475904
|
|
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
|
|
- export XMLLINT_INDENT=" "
|
|
- export PHPCS_DIR=/tmp/phpcs
|
|
- export PHPUNIT_DIR=/tmp/phpunit
|
|
- export PHPCS_BIN=$(if [[ $PHPCS_BRANCH == master ]]; then echo $PHPCS_DIR/bin/phpcs; else echo $PHPCS_DIR/scripts/phpcs; fi)
|
|
- mkdir -p $PHPCS_DIR && git clone --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git -b $PHPCS_BRANCH $PHPCS_DIR
|
|
- $PHPCS_BIN --config-set installed_paths $(pwd)
|
|
# Download PHPUnit 5.x for builds on PHP 7, nightly and HHVM as the PHPCS
|
|
# test suite is currently not compatible with PHPUnit 6.x.
|
|
# Fixed at a very specific PHPUnit version which is also compatible with HHVM.
|
|
- if [[ ${TRAVIS_PHP_VERSION:0:2} != "5." ]]; then wget -P $PHPUNIT_DIR https://phar.phpunit.de/phpunit-5.7.17.phar && chmod +x $PHPUNIT_DIR/phpunit-5.7.17.phar; fi
|
|
# Selectively adjust the ini values for the build image to test ini value dependent sniff features.
|
|
- if [[ "$SHORT_OPEN_TAGS" == "true" ]]; then echo "short_open_tag = On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
|
|
|
|
script:
|
|
# Lint the PHP files against parse errors.
|
|
- if [[ "$LINT" == "1" ]]; then if find . -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi
|
|
# Run the unit tests.
|
|
- if [[ ${TRAVIS_PHP_VERSION:0:2} == "5." && ${PHPCS_BRANCH:0:2} == "2." ]]; then phpunit --filter WordPress $(pwd)/Test/AllTests.php; fi
|
|
- if [[ ${TRAVIS_PHP_VERSION:0:2} == "5." && ${PHPCS_BRANCH:0:2} != "2." ]]; then phpunit --filter WordPress $PHPCS_DIR/tests/AllTests.php; fi
|
|
- if [[ ${TRAVIS_PHP_VERSION:0:2} != "5." && ${PHPCS_BRANCH:0:2} == "2." ]]; then php $PHPUNIT_DIR/phpunit-5.7.17.phar --filter WordPress $(pwd)/Test/AllTests.php; fi
|
|
- if [[ ${TRAVIS_PHP_VERSION:0:2} != "5." && ${PHPCS_BRANCH:0:2} != "2." ]]; then php $PHPUNIT_DIR/phpunit-5.7.17.phar --filter WordPress $PHPCS_DIR/tests/AllTests.php; fi
|
|
# Test for fixer conflicts by running the auto-fixers of the complete WPCS over the test case files.
|
|
# This is not an exhaustive test, but should give an early indication for typical fixer conflicts.
|
|
# For the first run, the exit code will be 1 (= all fixable errors fixed).
|
|
# `travis_retry` should then kick in to run the fixer again which should now return 0 (= no fixable errors found).
|
|
# All error codes for the PHPCBF: https://github.com/squizlabs/PHP_CodeSniffer/issues/1270#issuecomment-272768413
|
|
- if [[ "$SNIFF" == "1" ]]; then travis_retry $PHPCS_DIR/bin/phpcbf -p ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary; fi
|
|
# WordPress Coding Standards.
|
|
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
|
|
# @link http://pear.php.net/package/PHP_CodeSniffer/
|
|
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_BIN . --standard=./bin/phpcs.xml --runtime-set ignore_warnings_on_exit 1; fi
|
|
# Validate the xml files.
|
|
# @link http://xmlsoft.org/xmllint.html
|
|
- if [[ "$SNIFF" == "1" ]]; then xmllint --noout ./*/ruleset.xml; fi
|
|
- if [[ "$SNIFF" == "1" ]]; then xmllint --noout ./phpcs.xml.dist.sample; fi
|
|
# Check the code-style consistency of the xml files.
|
|
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress/ruleset.xml <(xmllint --format "./WordPress/ruleset.xml"); fi
|
|
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Core/ruleset.xml <(xmllint --format "./WordPress-Core/ruleset.xml"); fi
|
|
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Docs/ruleset.xml <(xmllint --format "./WordPress-Docs/ruleset.xml"); fi
|
|
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml"); fi
|
|
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-VIP/ruleset.xml <(xmllint --format "./WordPress-VIP/ruleset.xml"); fi
|
|
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample"); fi
|
|
# Validate the composer.json file.
|
|
# @link https://getcomposer.org/doc/03-cli.md#validate
|
|
- if [[ "$LINT" == "1" ]]; then composer validate --no-check-all --strict; fi
|