Last active
October 3, 2018 18:40
-
-
Save polbins/9c4e113e9ebb08ed17ee3c2349293109 to your computer and use it in GitHub Desktop.
Pre-push to run your lint and 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 | |
# Installation | |
# ============ | |
# 1. Add this snippet to: `<REPO>/.git/hooks/pre-push` | |
# 2. Make sure to `chmod a+x <REPO>/.git/hooks/pre-push` to make the code executable | |
# Check if we actually have commits to push | |
commits=`git log @{u}..` | |
if [ -z "$commits" ]; then | |
echo "no commits to push. aborting check..." | |
exit 0 | |
fi | |
LINT_CMD="gradle ktlint" # Command that runs your lint | |
$LINT_CMD | |
RESULT=$? | |
if [ $RESULT -ne 0 ]; then | |
echo "failed lint check '$LINT_CMD'" | |
exit 1 | |
fi | |
TEST_CMD="gradle app:testAlphaDebug" # Command that runs your tests | |
$TEST_CMD | |
RESULT=$? | |
if [ $RESULT -ne 0 ]; then | |
echo "failed tests check '$TEST_CMD'" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment