My Continuous Integration works pretty great using Codeship except one thing: stop deploying and alert us when unit tests are failing.
Here is our current commands:
The problem is whether gulp test
end with success or fail, the gulp build
builds.
I succeed to console.log()
my gulp test
exit status but I have no idea about how to make Codeship listen to this exit status.
Using @mlocker answer and this discussion on Github, I've found a workaround that works fine for me:
gulp.task('test', function (done) {
karma.start({}, function(exitStatus){
done(exitStatus ? "There are failing unit tests" : undefined);
});
});
The trick here is that if the exitStatus is different from 0, you'll get a formatError on "There are failing unit tests" which will exit gulp test
with 1
making Codeship to stop and consider the build as failed
.