Run:
chmod +x pre-push.sh
ln -s ../../pre-push.sh .git/hooks/pre-push
and the script will be executed before each git push. You can skip the hook by adding --no-verify
to your git push
.
#!/bin/sh | |
echo 'Running Rspec tests' | |
RUN_CHECK_CMD='bundle exec rspec spec -fd' | |
RUN_TESTS_OUTPUT=`${RUN_CHECK_CMD}` | |
if [ $? -eq 1 ] | |
then | |
echo "Can't commit! You've broken Rspec tests!!!" | |
exit 1 | |
fi | |
echo 'Running SCSS Lint' | |
RUN_CHECK_CMD='bundle exec scss-lint app/assets/stylesheets/' | |
RUN_TESTS_OUTPUT=`${RUN_CHECK_CMD}` | |
if [ $? -eq 1 ] | |
then | |
echo "Can't commit! You have scss lint offences!!!" | |
exit 1 | |
fi | |
echo 'Running Rubocop' | |
RUN_CHECK_CMD='bundle exec rubocop app spec -R --format simple' | |
RUN_TESTS_OUTPUT=`${RUN_CHECK_CMD}` | |
if [ $? -eq 1 ] | |
then | |
echo "Can't commit! You have rubocop offences!!!" | |
exit 1 | |
fi | |
echo "All checks passed. Congrats!\n" | |
exit 0 |