forked from epfl-lara/stainless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stainless-ci.sh
executable file
·180 lines (156 loc) · 4.36 KB
/
stainless-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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env bash
usage() {
cat <<EOM
Usage: stainless-ci.sh [options]
-h | -help Print this message
--bolts-dir <DIR> Directory where bolts is located (default: clones from GitHub).
--build-only Only build the project, do not run tests.
--skip-build Do not build the project (saves time if the build is already up-to-date).
--skip-bolts Do not run the Bolts benchmarks.
--skip-sbt-plugin Do not run the sbt plugin tests.
--skip-tests Do not run the unit and integration tests.
--install-solvers <DIR> Install the solvers required for the tests (cvc5, CVC4, and z3) FOR LINUX.
EOM
}
# Run the complete CI pipeline
# Record the time to compute the total duration
TIME_BEFORE=$(date +%s)
BUILD_ONLY=false
SKIP_BOLTS=false
SKIP_BUILD=false
SKIP_SBT_PLUGIN=false
SKIP_TESTS=false
# First parse the options
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h|--help)
usage
exit 0
;;
--bolts-dir)
BOLTS_DIR="$2"
shift # past argument
shift # past value
;;
--build-only)
BUILD_ONLY=true
shift # past argument
;;
--skip-bolts)
SKIP_BOLTS=true
shift # past argument
;;
--skip-build)
SKIP_BUILD=true
shift # past argument
;;
--skip-sbt-plugin)
SKIP_SBT_PLUGIN=true
shift # past argument
;;
--skip-tests)
SKIP_TESTS=true
shift # past argument
;;
--install-solvers)
SOLVERS_DIR="$2"
shift # past argument
shift # past value
;;
*) # unknown option
usage
exit 1
;;
esac
done
# Download the solvers
if [ -n "$SOLVERS_DIR" ]; then
TEMP_DIR="temp"
mkdir -p "$SOLVERS_DIR"
mkdir -p "$TEMP_DIR"
# cvc5
wget https://github.com/cvc5/cvc5/releases/download/cvc5-1.1.2/cvc5-Linux-static.zip -O "$TEMP_DIR/downloaded.zip" -q
unzip "$TEMP_DIR/downloaded.zip" -d "$TEMP_DIR"
CVC5_DIR=$(ls "$TEMP_DIR" | grep cvc5)
mv "$TEMP_DIR/$CVC5_DIR/bin/cvc5" "$SOLVERS_DIR/cvc5"
chmod +x "$SOLVERS_DIR/cvc5"
rm -rf "$TEMP_DIR"
# CVC4
wget https://cvc4.cs.stanford.edu/downloads/builds/x86_64-linux-opt/cvc4-1.8-x86_64-linux-opt -O "$SOLVERS_DIR/cvc4" -q
chmod +x "$SOLVERS_DIR/cvc4"
# z3
mkdir -p "$TEMP_DIR"
wget https://github.com/Z3Prover/z3/releases/download/z3-4.13.0/z3-4.13.0-x64-glibc-2.35.zip -O "$TEMP_DIR/downloaded.zip" -q
unzip "$TEMP_DIR/downloaded.zip" -d "$TEMP_DIR"
Z3_DIR=$(ls "$TEMP_DIR" | grep z3)
mv "$TEMP_DIR/$Z3_DIR/bin/z3" "$SOLVERS_DIR/z3"
chmod +x "$SOLVERS_DIR/z3"
rm -rf "$TEMP_DIR"
echo "************** Solvers Installed **************"
exit 0
fi
if [ "$SKIP_BUILD" = true ]; then
echo "************** Skipping build **************"
else
sbt universal:stage
if [ $? -ne 0 ]; then
echo "************** Failed to build the universal package **************"
exit 1
fi
if [ "$BUILD_ONLY" = true ]; then
echo "************** Build only done **************"
exit 0
fi
fi
if [ "$SKIP_TESTS" = true ]; then
echo "************** Skipping tests **************"
else
# Run the tests
sbt -batch -Dtestsuite-parallelism=5 test
if [ $? -ne 0 ]; then
echo "************** Unit tests failed **************"
exit 1
fi
# Run the integration tests
sbt -batch -Dtestsuite-parallelism=3 -Dtestcase-parallelism=5 it:test
if [ $? -ne 0 ]; then
echo "************** Integration tests failed **************"
exit 1
fi
fi
# Run the Bolts benchmarks
# if BOLTS_DIR is set, pass it to the script
if [ "$SKIP_BOLTS" = true ]; then
echo "************** Skipping Bolts tests **************"
else
if [ -z "$BOLTS_DIR" ]; then
bash bin/external-tests.sh --skip-build
else
bash bin/external-tests.sh --skip-build --bolts-dir $BOLTS_DIR
fi
if [ $? -ne 0 ]; then
echo "Bolts benchmarks failed"
exit 1
fi
fi
# Run sbt scripted
if [ "$SKIP_SBT_PLUGIN" = true ]; then
echo "************** Skipping sbt plugin tests **************"
else
sbt -batch scripted
if [ $? -ne 0 ]; then
echo "sbt scripted failed"
exit 1
fi
fi
# bash bin/build-slc-lib.sh
# if [ $? -ne 0 ]; then
# echo "build-slc-lib.sh failed"
# exit 1
# fi
TIME_AFTER=$(date +%s)
DURATION=$((TIME_AFTER - TIME_BEFORE))
echo ""
echo "********************************* CI PASSED! *********************************"
echo "Total time: $DURATION seconds"