Created
November 17, 2016 13:23
-
-
Save dave-burke/f58b6ce564f79b78b7275933dd00b0ea to your computer and use it in GitHub Desktop.
Git pre-commit hook for running gradle tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exit with non-zero (i.e. reject the commit) if anything fails, particularly | |
# the gradle tasks. | |
set -e | |
# change to the project root directory | |
cd $(git rev-parse --show-toplevel) | |
if [[ "$(git rev-parse --abbrev-ref HEAD)" == "dev" ]]; then | |
echo "Running unit tests before accepting commit to 'dev'" | |
./gradlew test | |
fi | |
if [[ "$(git rev-parse --abbrev-ref HEAD)" == "master" ]]; then | |
echo "Running unit and integration tests before accepting commit to 'master'" | |
./gradlew test integTest | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment