Changes to travis, globally install phpunit and wpcs when required, cache vendor and composer cache directories
This commit is contained in:
parent
986375862e
commit
b105550b47
22
.travis.yml
22
.travis.yml
|
@ -1,4 +1,5 @@
|
||||||
language: php
|
language: php
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
chrome: stable
|
chrome: stable
|
||||||
|
@ -8,6 +9,11 @@ addons:
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- vendor
|
||||||
|
- $HOME/.composer/cache
|
||||||
|
|
||||||
# Test main supported versions of PHP against latest WP.
|
# Test main supported versions of PHP against latest WP.
|
||||||
php:
|
php:
|
||||||
- 5.6
|
- 5.6
|
||||||
|
@ -45,6 +51,7 @@ matrix:
|
||||||
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
|
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- export PATH="$HOME/.composer/vendor/bin:$PATH"
|
||||||
- |
|
- |
|
||||||
# Remove Xdebug for a huge performance increase:
|
# Remove Xdebug for a huge performance increase:
|
||||||
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
|
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
|
||||||
|
@ -52,9 +59,18 @@ before_script:
|
||||||
else
|
else
|
||||||
echo "xdebug.ini does not exist"
|
echo "xdebug.ini does not exist"
|
||||||
fi
|
fi
|
||||||
- export PATH="$HOME/.config/composer/vendor/bin:$PATH"
|
- |
|
||||||
- bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION
|
# Install WP Test suite, install PHPUnit globally if needed:
|
||||||
- bash tests/bin/travis.sh before
|
if [[ ! -z "$WP_VERSION" ]] ; then
|
||||||
|
bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION
|
||||||
|
composer global require "phpunit/phpunit=4.8.*|5.7.*"
|
||||||
|
fi
|
||||||
|
- |
|
||||||
|
# Install wpcs globally if needed:
|
||||||
|
if [[ ${RUN_PHPCS} == 1 ]]; then
|
||||||
|
composer global require wp-coding-standards/wpcs
|
||||||
|
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
|
||||||
|
fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- bash tests/bin/phpunit.sh
|
- bash tests/bin/phpunit.sh
|
||||||
|
|
|
@ -13,8 +13,10 @@ DB_HOST=${4-localhost}
|
||||||
WP_VERSION=${5-latest}
|
WP_VERSION=${5-latest}
|
||||||
SKIP_DB_CREATE=${6-false}
|
SKIP_DB_CREATE=${6-false}
|
||||||
|
|
||||||
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
|
TMPDIR=${TMPDIR-/tmp}
|
||||||
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
|
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
|
||||||
|
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
|
||||||
|
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}
|
||||||
|
|
||||||
download() {
|
download() {
|
||||||
if [ `which curl` ]; then
|
if [ `which curl` ]; then
|
||||||
|
@ -24,8 +26,15 @@ download() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)?(^-) ]]; then
|
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
|
||||||
WP_TESTS_TAG="tags/$WP_VERSION"
|
WP_TESTS_TAG="branches/$WP_VERSION"
|
||||||
|
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
||||||
|
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
|
||||||
|
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
|
||||||
|
WP_TESTS_TAG="tags/${WP_VERSION%??}"
|
||||||
|
else
|
||||||
|
WP_TESTS_TAG="tags/$WP_VERSION"
|
||||||
|
fi
|
||||||
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
||||||
WP_TESTS_TAG="trunk"
|
WP_TESTS_TAG="trunk"
|
||||||
else
|
else
|
||||||
|
@ -51,18 +60,34 @@ install_wp() {
|
||||||
mkdir -p $WP_CORE_DIR
|
mkdir -p $WP_CORE_DIR
|
||||||
|
|
||||||
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
|
||||||
mkdir -p /tmp/wordpress-nightly
|
mkdir -p $TMPDIR/wordpress-nightly
|
||||||
download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
|
download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip
|
||||||
unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
|
unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/
|
||||||
mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
|
mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR
|
||||||
else
|
else
|
||||||
if [ $WP_VERSION == 'latest' ]; then
|
if [ $WP_VERSION == 'latest' ]; then
|
||||||
local ARCHIVE_NAME='latest'
|
local ARCHIVE_NAME='latest'
|
||||||
|
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then
|
||||||
|
# https serves multiple offers, whereas http serves single.
|
||||||
|
download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json
|
||||||
|
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
|
||||||
|
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
|
||||||
|
LATEST_VERSION=${WP_VERSION%??}
|
||||||
|
else
|
||||||
|
# otherwise, scan the releases and get the most up to date minor version of the major release
|
||||||
|
local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'`
|
||||||
|
LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1)
|
||||||
|
fi
|
||||||
|
if [[ -z "$LATEST_VERSION" ]]; then
|
||||||
|
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
||||||
|
else
|
||||||
|
local ARCHIVE_NAME="wordpress-$LATEST_VERSION"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
||||||
fi
|
fi
|
||||||
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
|
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz
|
||||||
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
|
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
|
||||||
|
@ -91,9 +116,7 @@ install_test_suite() {
|
||||||
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
|
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||||
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
|
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||||
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
|
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||||
# escape the regex delim if not already escaped (i.e. if preceded by an even number of backslashes)
|
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||||
E_DB_PASS=$(echo $DB_PASS | sed -E -e 's%([/&\\])%\\\1%g')
|
|
||||||
sed $ioption "s/yourpasswordhere/${E_DB_PASS}/" "$WP_TESTS_DIR"/wp-tests-config.php
|
|
||||||
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
|
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,6 @@ if [[ ${RUN_PHPCS} == 1 ]]; then
|
||||||
|
|
||||||
if [ "$CHANGED_FILES" != "" ]; then
|
if [ "$CHANGED_FILES" != "" ]; then
|
||||||
echo "Running Code Sniffer."
|
echo "Running Code Sniffer."
|
||||||
./vendor/bin/phpcs --ignore=$IGNORE --encoding=utf-8 -s -n -p $CHANGED_FILES
|
phpcs --ignore=$IGNORE --encoding=utf-8 -s -n -p $CHANGED_FILES
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -5,7 +5,7 @@ if [[ ${RUN_PHPCS} == 1 ]] || [[ ${RUN_E2E} == 1 ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${RUN_CODE_COVERAGE} == 1 ]]; then
|
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
|
phpdbg -qrr -d memory_limit=-1 phpunit -c phpunit.xml --coverage-clover=coverage.clover --exclude-group=timeout
|
||||||
else
|
else
|
||||||
phpunit -c phpunit.xml
|
phpunit -c phpunit.xml
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -7,7 +7,7 @@ if [[ ${RUN_E2E} == 1 ]]; then
|
||||||
export BASE_URL="$WP_SITE_URL"
|
export BASE_URL="$WP_SITE_URL"
|
||||||
export DISPLAY=:99.0
|
export DISPLAY=:99.0
|
||||||
sh -e /etc/init.d/xvfb start
|
sh -e /etc/init.d/xvfb start
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|
||||||
# Run the tests
|
# Run the tests
|
||||||
npm test
|
npm test
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# usage: travis.sh before|after
|
# usage: travis.sh before|after
|
||||||
|
|
||||||
if [ $1 == 'before' ]; then
|
|
||||||
|
|
||||||
composer global require "phpunit/phpunit=6.*"
|
|
||||||
|
|
||||||
if [[ ${RUN_PHPCS} == 1 ]]; then
|
|
||||||
composer install
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $1 == 'after' ]; then
|
if [ $1 == 'after' ]; then
|
||||||
|
|
||||||
if [[ ${RUN_CODE_COVERAGE} == 1 ]]; then
|
if [[ ${RUN_CODE_COVERAGE} == 1 ]]; then
|
||||||
|
@ -22,9 +12,9 @@ if [ $1 == 'after' ]; then
|
||||||
|
|
||||||
if [[ ${RUN_E2E} == 1 && $(ls -A $TRAVIS_BUILD_DIR/screenshots) ]]; then
|
if [[ ${RUN_E2E} == 1 && $(ls -A $TRAVIS_BUILD_DIR/screenshots) ]]; then
|
||||||
if [[ -z "${ARTIFACTS_KEY}" ]]; then
|
if [[ -z "${ARTIFACTS_KEY}" ]]; then
|
||||||
echo "Screenshots were not uploaded. Please run the e2e tests locally to see failures."
|
echo "Screenshots were not uploaded. Please run the e2e tests locally to see failures."
|
||||||
else
|
else
|
||||||
curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/master/install | bash
|
curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/master/install | bash
|
||||||
artifacts upload
|
artifacts upload
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue