forked from google/protobuf.dart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci.sh
executable file
·126 lines (112 loc) · 3.11 KB
/
ci.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
# Created with package:mono_repo v3.4.6
# Support built in commands on windows out of the box.
function pub() {
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
command pub.bat "$@"
else
command pub "$@"
fi
}
function dartfmt() {
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
command dartfmt.bat "$@"
else
command dartfmt "$@"
fi
}
function dartanalyzer() {
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
command dartanalyzer.bat "$@"
else
command dartanalyzer "$@"
fi
}
if [[ -z ${PKGS} ]]; then
echo -e '\033[31mPKGS environment variable must be set! - TERMINATING JOB\033[0m'
exit 64
fi
if [[ "$#" == "0" ]]; then
echo -e '\033[31mAt least one task argument must be provided! - TERMINATING JOB\033[0m'
exit 64
fi
SUCCESS_COUNT=0
declare -a FAILURES
for PKG in ${PKGS}; do
echo -e "\033[1mPKG: ${PKG}\033[22m"
EXIT_CODE=0
pushd "${PKG}" >/dev/null || EXIT_CODE=$?
if [[ ${EXIT_CODE} -ne 0 ]]; then
echo -e "\033[31mPKG: '${PKG}' does not exist - TERMINATING JOB\033[0m"
exit 64
fi
pub upgrade --no-precompile || EXIT_CODE=$?
if [[ ${EXIT_CODE} -ne 0 ]]; then
echo -e "\033[31mPKG: ${PKG}; 'pub upgrade' - FAILED (${EXIT_CODE})\033[0m"
FAILURES+=("${PKG}; 'pub upgrade'")
else
for TASK in "$@"; do
EXIT_CODE=0
echo
echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m"
case ${TASK} in
command_0)
echo './../tool/setup.sh'
./../tool/setup.sh || EXIT_CODE=$?
;;
command_1)
echo './compile_protos.sh'
./compile_protos.sh || EXIT_CODE=$?
;;
command_2)
echo 'make protos'
make protos || EXIT_CODE=$?
;;
dartanalyzer_0)
echo 'dartanalyzer --fatal-warnings .'
dartanalyzer --fatal-warnings . || EXIT_CODE=$?
;;
dartanalyzer_1)
echo 'dartanalyzer --fatal-infos --fatal-warnings lib test'
dartanalyzer --fatal-infos --fatal-warnings lib test || EXIT_CODE=$?
;;
dartanalyzer_2)
echo 'dartanalyzer --fatal-infos --fatal-warnings .'
dartanalyzer --fatal-infos --fatal-warnings . || EXIT_CODE=$?
;;
dartfmt)
echo 'dartfmt -n --set-exit-if-changed .'
dartfmt -n --set-exit-if-changed . || EXIT_CODE=$?
;;
test)
echo 'pub run test'
pub run test || EXIT_CODE=$?
;;
*)
echo -e "\033[31mUnknown TASK '${TASK}' - TERMINATING JOB\033[0m"
exit 64
;;
esac
if [[ ${EXIT_CODE} -ne 0 ]]; then
echo -e "\033[31mPKG: ${PKG}; TASK: ${TASK} - FAILED (${EXIT_CODE})\033[0m"
FAILURES+=("${PKG}; TASK: ${TASK}")
else
echo -e "\033[32mPKG: ${PKG}; TASK: ${TASK} - SUCCEEDED\033[0m"
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
fi
done
fi
echo
echo -e "\033[32mSUCCESS COUNT: ${SUCCESS_COUNT}\033[0m"
if [ ${#FAILURES[@]} -ne 0 ]; then
echo -e "\033[31mFAILURES: ${#FAILURES[@]}\033[0m"
for i in "${FAILURES[@]}"; do
echo -e "\033[31m $i\033[0m"
done
fi
popd >/dev/null || exit 70
echo
done
if [ ${#FAILURES[@]} -ne 0 ]; then
exit 1
fi