Skip to content

Commit

Permalink
[#766] Stop Travis build if a dependency install fails
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vitorbaptista committed Oct 17, 2013
1 parent 2ce2164 commit 3a60c2e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -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:
Expand Down
26 changes: 4 additions & 22 deletions bin/travis-build → 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'
Expand Down Expand Up @@ -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`
22 changes: 22 additions & 0 deletions 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`

0 comments on commit 3a60c2e

Please sign in to comment.