Skip to content

Instantly share code, notes, and snippets.

@epintos
Created March 7, 2016 20:04
Show Gist options
  • Save epintos/2e212a91d9a45658110a to your computer and use it in GitHub Desktop.
Save epintos/2e212a91d9a45658110a to your computer and use it in GitHub Desktop.
Git Pre Push example to check linters and run tests
#!/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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment