Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Clarify the travis tests using build stages #3150

Merged
merged 4 commits into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 31 additions & 57 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,69 +18,43 @@ before_install:
- nvm install 6.11.1 && nvm use 6.11.1
- npm install --global npm@5

matrix:
jobs:
include:
- php: 7.1
- stage: unit
php: 5.6
script: composer install && ./vendor/bin/phpcs

- stage: unit
script:
- npm install || exit 1
- npm run ci || exit 1

- stage: unit
php: 7.1
env: WP_VERSION=latest
- php: 5.6
script:
- ./bin/run-wp-unit-tests.sh

- stage: unit
php: 5.6
env: WP_VERSION=latest
- php: 7.1
script:
- ./bin/run-wp-unit-tests.sh

- stage: unit
php: 7.1
env: WP_VERSION=latest SWITCH_TO_PHP=5.3
- php: 7.1
env: WP_VERSION=latest SWITCH_TO_PHP=5.2
- php: 5.6
env: TRAVISCI=phpcs
- php: 7.1
env: TRAVISCI=js
script:
- ./bin/run-wp-unit-tests.sh

before_script:
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- |
if [[ ! -z "$WP_VERSION" ]] ; then
set -e
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
source bin/install-php-phpunit.sh
set +e
fi
- |
if [[ "$TRAVISCI" == "phpcs" ]] ; then
composer install
fi
- stage: unit
php: 7.1
env: WP_VERSION=latest SWITCH_TO_PHP=5.2
script:
- ./bin/run-wp-unit-tests.sh

script:
- |
if [[ ! -z "$WP_VERSION" ]] ; then
# Run the build because otherwise there will be a bunch of warnings about
# failed `stat` calls from `filemtime()`.
npm install || exit 1
npm run build || exit 1
# Make sure phpegjs parser is up to date
node bin/create-php-parser.js || exit 1
if ! git diff --quiet --exit-code lib/parser.php; then
echo 'ERROR: The PEG parser has been updated, but the generated PHP version'
echo ' (lib/parser.php) has not. Run `bin/create-php-parser.js` and'
echo ' commit the resulting changes to resolve this.'
sleep .2 # Otherwise Travis doesn't want to print the whole message
exit 1
fi
echo Running with the following versions:
php -v
phpunit --version
# Check parser syntax
php lib/parser.php || exit 1
# Run PHPUnit tests
phpunit || exit 1
WP_MULTISITE=1 phpunit || exit 1
fi
- |
if [[ "$TRAVISCI" == "phpcs" ]] ; then
./vendor/bin/phpcs
fi
- |
if [[ "$TRAVISCI" == "js" ]] ; then
npm install || exit 1
npm run ci || exit 1
fi
stages:
- unit

before_deploy:
- npm install
Expand Down
28 changes: 28 additions & 0 deletions bin/run-wp-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

cd "$(dirname "$0")/../"

export PATH="$HOME/.composer/vendor/bin:$PATH"
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
source bin/install-php-phpunit.sh
# Run the build because otherwise there will be a bunch of warnings about
# failed `stat` calls from `filemtime()`.
npm install || exit 1
npm run build || exit 1
# Make sure phpegjs parser is up to date
node bin/create-php-parser.js || exit 1
if ! git diff --quiet --exit-code lib/parser.php; then
echo 'ERROR: The PEG parser has been updated, but the generated PHP version'
echo ' (lib/parser.php) has not. Run `bin/create-php-parser.js` and'
echo ' commit the resulting changes to resolve this.'
sleep .2 # Otherwise Travis doesn't want to print the whole message
exit 1
fi
echo Running with the following versions:
php -v
phpunit --version
# Check parser syntax
php lib/parser.php || exit 1
# Run PHPUnit tests
phpunit || exit 1
WP_MULTISITE=1 phpunit || exit 1