sudo: false dist: trusty cache: apt: true language: - php php: - 5.4 - 5.5 - 5.6 - 7.0 - 7.1 env: # Branch for patches against 2.x. `master` is now 3.x which WPCS is not (yet) compatible with. - PHPCS_BRANCH=2.9 LINT=1 # Tagged release - PHPCS_BRANCH=2.9.0 matrix: fast_finish: true include: # Run PHPCS against WPCS. I just picked to run it against 5.5. - php: 5.5 env: PHPCS_BRANCH=2.9 SNIFF=1 addons: apt: packages: - libxml2-utils # Run against PHPCS 3.0. I just picked to run it against 5.6. - php: 5.6 env: PHPCS_BRANCH=master # Run against HHVM and PHP nightly. - php: hhvm sudo: required dist: trusty group: edge env: PHPCS_BRANCH=2.9 LINT=1 - php: nightly env: PHPCS_BRANCH=2.9 LINT=1 # Test PHP 5.3 with short_open_tags set to On (is Off by default) - php: 5.3 env: PHPCS_BRANCH=2.9 SHORT_OPEN_TAGS=true dist: precise - php: 5.3 env: PHPCS_BRANCH=2.9 dist: precise - php: 5.3 env: PHPCS_BRANCH=2.9.0 dist: precise - php: 5.2 env: PHPCS_BRANCH=2.9 dist: precise - php: 5.2 env: PHPCS_BRANCH=2.9.0 dist: precise allow_failures: # Allow failures for unstable builds. - php: nightly - php: hhvm - env: PHPCS_BRANCH=master before_install: - 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." ]]; then phpunit --filter WordPress /tmp/phpcs/tests/AllTests.php; fi - if [[ ${TRAVIS_PHP_VERSION:0:2} != "5." ]]; then php $PHPUNIT_DIR/phpunit-5.7.17.phar --filter WordPress /tmp/phpcs/tests/AllTests.php; fi # WordPress Coding Standards. # @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards # @link http://pear.php.net/package/PHP_CodeSniffer/ # -p flag: Show progress of the run. # -s flag: Show sniff codes in all reports. # -v flag: Print verbose output. # -n flag: Do not print warnings. (shortcut for --warning-severity=0) # --standard: Use WordPress as the standard. # --extensions: Only sniff PHP files. - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs -p -s -n . --standard=./bin/phpcs.xml --extensions=php; 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