MDL-55048 travis: check npm/grunt on multiple npm versions

Check npm install and grunt execution on the higest and lowest node
versions. Included some minor tweaks along the way:

* Move the grunt execution into scripts part of the configuration (that way
  the grunt output is not collapsed and is easily visible in build output).

* Restructure the install section to be task based (thanks to Eloy for
  the suggestion) and as such, don't run composer install on the grunt
  task (speed up the build slightly).

* Switch around the grunt job to a matrix include so that every
  variation of grunt job doesn't need to be excluded.
  ( https://docs.travis-ci.com/user/customizing-the-build/#Explicity-Including-Jobs )
This commit is contained in:
Dan Poltawski 2016-07-07 10:54:30 +01:00
parent 9b62a3eb71
commit 7402479c45

View File

@ -36,15 +36,20 @@ env:
# Perform an upgrade test too.
- DB=pgsql TASK=UPGRADE
# Run a check for unbuilt files with Grunt.
- DB=none TASK=GRUNT
matrix:
# Enable fast finish.
# This will fail the build if a single job fails (except those in allow_failures).
# It will not stop the jobs from running.
fast_finish: true
include:
# Run grunt/npm install on lowest supported npm version
- php: 7
env: DB=none TASK=GRUNT NVM_VERSION='4'
# Run grunt/npm install on highest version ('node' is an alias for the latest node.js version.)
- php: 7
env: DB=none TASK=GRUNT NVM_VERSION='node'
exclude:
# MySQL - it's just too slow.
# Exclude it on all versions except for 7.0
@ -52,10 +57,6 @@ matrix:
- env: DB=mysqli TASK=PHPUNIT
php: 5.6
# One grunt execution is enough.
- env: DB=none TASK=GRUNT
php: 5.6
# Moodle 2.7 is not compatible with PHP 7 for the upgrade test.
- env: DB=pgsql TASK=UPGRADE
php: 7.0
@ -69,14 +70,26 @@ install:
# Disable xdebug. We aren't generating code coverage, and it has a huge impact upon test performance.
- rm /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
# Set the encrypted GITHUB_TOKEN if it's available to raise the API limit.
- if [ -n "$GITHUB_APITOKEN" ]; then composer config github-oauth.github.com $GITHUB_APITOKEN; fi
- echo 'auth.json' >> .git/info/exclude
- >
if [ "$TASK" = 'PHPUNIT' ];
then
if [ -n "$GITHUB_APITOKEN" ]; then
composer config github-oauth.github.com $GITHUB_APITOKEN;
echo 'auth.json' >> .git/info/exclude
fi
# Install composer dependencies.
# We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
# Typically it should be able to use the Composer cache if any other job has already completed before we started here.
- travis_retry composer install --prefer-dist --no-interaction
# Install composer dependencies.
# We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
# Typically it should be able to use the Composer cache if any other job has already completed before we started here.
travis_retry composer install --prefer-dist --no-interaction;
fi
- >
if [ "$TASK" = 'GRUNT' ];
then
nvm install $NVM_VERSION ;
nvm use $NVM_VERSION ;
fi
before_script:
- >
@ -143,9 +156,8 @@ before_script:
- >
if [ "$TASK" = 'GRUNT' ];
then
npm install ;
npm install -g grunt ;
grunt ;
npm install --no-spin;
npm install --no-spin -g grunt ;
fi
########################################################################
@ -217,6 +229,7 @@ script:
- >
if [ "$TASK" = 'GRUNT' ];
then
grunt ;
# Add all files to the git index and then run diff --cached to see all changes.
# This ensures that we get the status of all files, including new files.
git add . ;