git pre commit hookでテストに失敗したらコミットしないようにする。
gitでコミットする前にrspecとjasmine-headless-webkitを実行する。
.git/hooks/pre-commit
#!/bin/sh if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then # First try to load from a user install source "$HOME/.rvm/scripts/rvm" elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then # Then try to load from a root install source "/usr/local/rvm/scripts/rvm" else printf "ERROR: An RVM installation was not found.\n" fi bundle exec rake spec r=$? if [ $r -ne 0 ] ; then echo "error: rspec failed" exit $r fi bundle exec rake assets:precompile jasmine-headless-webkit r=$? bundle exec rake assets:clean if [ $r -ne 0 ] ; then echo "error: jasumine failed" exit $r fi
Jenkins氏が休暇中だったときのために
git pullした場合も自動でテストが走るように
post-mergeにシンボリックリンクを貼っておいた。
ln -s .git/hooks/pre-commit .git/hooks/post-merge
参考
https://gist.github.com/1313812
https://gist.github.com/1475724