Skip to content

Instantly share code, notes, and snippets.

@dave-burke
Created November 17, 2016 13:23
Show Gist options
  • Save dave-burke/f58b6ce564f79b78b7275933dd00b0ea to your computer and use it in GitHub Desktop.
Save dave-burke/f58b6ce564f79b78b7275933dd00b0ea to your computer and use it in GitHub Desktop.
Git pre-commit hook for running gradle tests
#!/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