-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpre-commit.sh
46 lines (37 loc) · 961 Bytes
/
pre-commit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
#
# To skip running tests, run the --no-verify argument.
# i.e git commit --no-verify
#
## Run unit tests with gradle wrapper.
./gradlew test --daemon
# Store the last exit code in a variable.
testResult=$?
# Perform checks
if [ $testResult -ne 0 ]
then
echo "Tests failed to run, fix them to proceed with the commit"
exit 1
fi
## Run instrumentation tests with gradle wrapper.
./gradlew test connectedAndroidTest --daemon
# Store the last exit code in a variable.
instrumentationTestResult=$?
# Perform checks
if [ $instrumentationTestResult -ne 0 ]
then
echo "Tests failed to run, fix them to proceed with the commit"
exit 1
fi
## Run checkstyle to check the code quality.
./gradlew check --daemon
# Store the last exit code in a variable.
checkResult=$?
# Perform checks
if [ $checkResult -ne 0 ]
then
echo "Code violations were found, fix them to proceed with the commit"
exit 1
fi
# You can commit
exit 0