Merge pull request #17113 from woocommerce/add/travis-phpcs

Run PHPCS in Travis CI
This commit is contained in:
Mike Jolley 2017-11-01 12:18:44 +00:00 committed by GitHub
commit c17e76adc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -23,11 +23,13 @@ matrix:
before_script:
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- if [[ $TRAVIS_PHP_VERSION == '7.1' ]]; then composer install; fi
- bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION
- bash tests/bin/travis.sh before
script:
- bash tests/bin/phpunit.sh
- bash tests/bin/phpcs.sh
after_script:
- bash tests/bin/travis.sh after

View File

@ -2,14 +2,14 @@
/**
* WooCommerce Webhook functions
*
* @author WooThemes
* @author Automattic
* @category Core
* @package WooCommerce/Functions
* @version 2.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit; // Exit if accessed directly.
}
/**

11
tests/bin/phpcs.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
if [[ $TRAVIS_PHP_VERSION == '7.1' ]]; then
CHANGED_FILES=`git diff --name-only --diff-filter=ACMR $TRAVIS_COMMIT_RANGE | grep \\\\.php | awk '{print}' ORS=' '`
IGNORE="tests/cli/,apigen/,includes/gateways/simplify-commerce/includes/,includes/libraries/,includes/api/legacy/"
if [ "$CHANGED_FILES" != "" ]; then
echo "Running Code Sniffer."
./vendor/bin/phpcs --ignore=$IGNORE --standard=./phpcs.ruleset.xml --encoding=utf-8 -n -p $CHANGED_FILES
fi
fi