-
Notifications
You must be signed in to change notification settings - Fork 8
/
pre-commit.sh
executable file
·87 lines (74 loc) · 1.86 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
set -euo pipefail
source ./scripts/functions.sh
source ./scripts/test-api.sh
function usage() {
cat <<USAGE
A script to run the DCS unit, integration, and acceptance tests locally. Runs all tests by default.
Usage:
$0 [-dig]
Options:
-u run the unit tests
-i run all integration tests
-g running in GitHub actions
-s run against sandpit
USAGE
}
RUN_UNIT=0
RUN_INTEGRATION=0
IN_GITHUB_ACTIONS=0
TF_ACCOUNT_MANAGEMENT=0
SANDPIT=0
if [[ $# -eq 0 ]] || [[ ( $# -eq 1 && ${1} == "-l" ) ]]; then
RUN_UNIT=1
RUN_INTEGRATION=1
fi
while getopts "uigts" opt; do
case ${opt} in
u)
RUN_UNIT=1
;;
i)
RUN_INTEGRATION=1
;;
*)
usage
exit 1
;;
esac
done
auth_api_pre_commit_start_seconds=$SECONDS
if [[ ${RUN_UNIT} -eq 1 ]]; then
printf "\nRunning build and unit tests...\n"
run_unit_tests_start_seconds=$SECONDS
set +e
./gradlew --parallel clean build -x integration-tests:test -x account-management-integration-tests:test
build_and_test_exit_code=$?
set -e
record_timings "run-unit-tests" run_unit_tests_start_seconds $SECONDS false
if [ ${build_and_test_exit_code} -ne 0 ]; then
printf "\nBuild and test failed.\n"
exit 1
fi
fi
if [ ${RUN_INTEGRATION} -eq 1 ] || [ ${TF_ACCOUNT_MANAGEMENT} -eq 1 ]; then
build_and_test_exit_code=0
if [[ ${RUN_INTEGRATION} -eq 1 ]]; then
set +e
run-integration-tests
build_and_test_exit_code=$?
set -e
fi
fi
record_timings "auth api pre-commit total" auth_api_pre_commit_start_seconds $SECONDS true
printf "\nauth api pre-commit task timings:\n\n"
for i in "${task_timings[@]}"; do echo "$i"; done
printf "\n"
if [ ${build_and_test_exit_code} -ne 0 ]; then
printf "\npre-commit failed.\n"
exit ${build_and_test_exit_code}
else
if [[ ${IN_GITHUB_ACTIONS} -eq 0 ]]; then
funky_success
fi
fi