diff --git a/plugins/woocommerce-admin/.travis.yml b/plugins/woocommerce-admin/.travis.yml index 8c285ed2823..2913617588e 100755 --- a/plugins/woocommerce-admin/.travis.yml +++ b/plugins/woocommerce-admin/.travis.yml @@ -1,7 +1,25 @@ sudo: false -language: node_js + +language: php +php: + - 5.6 + - 7.0 + - 7.1 + +env: + - WP_VERSION=latest WP_MULTISITE=0 + +before_script: + - phpenv config-rm xdebug.ini + - export PATH="$HOME/.composer/vendor/bin:$PATH" + - bash bin/install-wp-tests.sh wc_admin_test root '' localhost $WP_VERSION + - bash bin/travis.sh before + + node_js: - "8" script: - npm run lint - npm test + - bash bin/phpunit.sh + - bash bin/phpcs.sh diff --git a/plugins/woocommerce-admin/bin/phpcs.sh b/plugins/woocommerce-admin/bin/phpcs.sh new file mode 100755 index 00000000000..d46915c7784 --- /dev/null +++ b/plugins/woocommerce-admin/bin/phpcs.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +if [[ ${RUN_PHPCS} == 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 --encoding=utf-8 -n -p $CHANGED_FILES + fi +fi diff --git a/plugins/woocommerce-admin/bin/phpunit.sh b/plugins/woocommerce-admin/bin/phpunit.sh new file mode 100755 index 00000000000..458c40ac1b1 --- /dev/null +++ b/plugins/woocommerce-admin/bin/phpunit.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +if [[ ${RUN_CODE_COVERAGE} == 1 ]]; then + phpdbg -qrr -d memory_limit=-1 $HOME/.composer/vendor/bin/phpunit -c phpunit.xml --coverage-clover=coverage.clover --exclude-group=timeout +else + phpunit -c phpunit.xml +fi diff --git a/plugins/woocommerce-admin/bin/travis.sh b/plugins/woocommerce-admin/bin/travis.sh new file mode 100755 index 00000000000..c0411113220 --- /dev/null +++ b/plugins/woocommerce-admin/bin/travis.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# usage: travis.sh before|after + +if [ $1 == 'before' ]; then + + composer global require "phpunit/phpunit=6.*" + + if [[ ${RUN_PHPCS} == 1 ]]; then + composer install + fi + +fi