Skip to content

Instantly share code, notes, and snippets.

@ggaona
Created May 7, 2021 00:24
Show Gist options
  • Save ggaona/0473c685bf03125e2b81d1720125de0a to your computer and use it in GitHub Desktop.
Save ggaona/0473c685bf03125e2b81d1720125de0a to your computer and use it in GitHub Desktop.
Minitest & Brakeman pre-push git hook
#!/bin/bash
# Execute tests (Minitest, Brakeman) before committing; aborts push if any
# test fails.
# By ggaona
# Execute brakeman
echo "[Brakeman]"
bundle exec brakeman --color
# Docker alternative
# docker exec <container_name> brakeman --color
# Abort push if failed tests are found
if [ $? -ne 0 ]; then
echo "Push aborted."
exit 1
fi
# Execute minitest
echo "[Test Suite]"
bundle exec rails test -c
# Docker alternative
# docker exec <container_name> rails test -c
# Abort push if failed tests are found
if [ $? -ne 0 ]; then
echo "Push aborted."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment