From 3a60c2e2420350631742f8d0330be2f002d581eb Mon Sep 17 00:00:00 2001 From: Vitor Baptista Date: Wed, 16 Oct 2013 21:24:26 -0300 Subject: [PATCH] [#766] Stop Travis build if a dependency install fails To do so, I needed to split our ./bin/travis-build in two files, one with the deps install, and one with the test run. Doing so allows me to use the "install" directive in Travis, and break the build as soon as something fails with it. --- .travis.yml | 3 ++- ...avis-build => travis-install-dependencies} | 26 +++---------------- bin/travis-run-tests | 22 ++++++++++++++++ 3 files changed, 28 insertions(+), 23 deletions(-) rename bin/{travis-build => travis-install-dependencies} (73%) create mode 100755 bin/travis-run-tests diff --git a/.travis.yml b/.travis.yml index af450298b6c..43b6cc3776a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ python: env: - PGVERSION=9.1 - PGVERSION=8.4 -script: ./bin/travis-build +install: ./bin/travis-install-dependencies +script: ./bin/travis-run-tests notifications: irc: channels: diff --git a/bin/travis-build b/bin/travis-install-dependencies similarity index 73% rename from bin/travis-build rename to bin/travis-install-dependencies index 51e633781b4..306d6e1f166 100755 --- a/bin/travis-build +++ b/bin/travis-install-dependencies @@ -1,4 +1,7 @@ -#!/bin/sh +#!/bin/bash + +# Exit immediately if any command fails +set -e # Drop Travis' postgres cluster if we're building using a different pg version TRAVIS_PGVERSION='9.1' @@ -51,24 +54,3 @@ else fi cat test-core.ini - -# Run mocha front-end tests -# We need ckan to be running for some tests -paster serve test-core.ini & -sleep 5 # Make sure the server has fully started -mocha-phantomjs http://localhost:5000/base/test/index.html -# Did an error occur? -MOCHA_ERROR=$? -# We are done so kill ckan -killall paster - -# And finally, run the nosetests -nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext -# Did an error occur? -NOSE_ERROR=$? - -[ "0" -ne "$MOCHA_ERROR" ] && echo MOCKA tests have failed -[ "0" -ne "$NOSE_ERROR" ] && echo NOSE tests have failed - -# If an error occurred in our tests make sure travis knows -exit `expr $MOCHA_ERROR + $NOSE_ERROR` diff --git a/bin/travis-run-tests b/bin/travis-run-tests new file mode 100755 index 00000000000..83f6d333e0d --- /dev/null +++ b/bin/travis-run-tests @@ -0,0 +1,22 @@ +#!/bin/bash + +# Run mocha front-end tests +# We need ckan to be running for some tests +paster serve test-core.ini & +sleep 5 # Make sure the server has fully started +mocha-phantomjs http://localhost:5000/base/test/index.html +# Did an error occur? +MOCHA_ERROR=$? +# We are done so kill ckan +killall paster + +# And finally, run the nosetests +nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext +# Did an error occur? +NOSE_ERROR=$? + +[ "0" -ne "$MOCHA_ERROR" ] && echo MOCKA tests have failed +[ "0" -ne "$NOSE_ERROR" ] && echo NOSE tests have failed + +# If an error occurred in our tests make sure travis knows +exit `expr $MOCHA_ERROR + $NOSE_ERROR`