forked from ucsd-progsys/liquidhaskell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis
executable file
·162 lines (120 loc) · 3.1 KB
/
travis
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
#!/bin/bash
set -eu
set -o pipefail
## Helper Functions
function loud {
echo "$ $@"
$@
}
function stack {
$HOME/.local/bin/stack --no-terminal "$@"
}
# Source: https://github.com/travis-ci/travis-build/blob/fc4ae8a2ffa1f2b3a2f62533bbc4f8a9be19a8ae/lib/travis/build/script/templates/header.sh#L104-L123
RED="\033[31;1m"
GREEN="\033[32;1m"
RESET="\033[0m"
function travis_retry {
local result=0
local count=1
while [ $count -le 3 ]; do
[ $result -ne 0 ] && {
echo -e "\n${RED}The command \"$@\" failed. Retrying, $count of 3.${RESET}\n" >&2
}
set +e
"$@"
result=$?
set -e
[ $result -eq 0 ] && break
count=$(($count + 1))
sleep 1
done
[ $count -eq 4 ] && {
echo "\n${RED}The command \"$@\" failed 3 times.${RESET}\n" >&2
}
return $result
}
function prevent_timeout {
local cmd="$@"
$cmd &
local cmd_pid=$!
poke_stdout &
local poke_pid=$!
wait $cmd_pid
exit_code=$?
kill $poke_pid
(wait $poke_pid 2>/dev/null) || true
return $exit_code
}
function poke_stdout {
# Print an invisible character every minute
while true; do
echo -ne "\xE2\x80\x8B"
sleep 60
done
}
function pastebin {
curl -s -F 'clbin=<-' https://clbin.com
}
## Setup Stages
function install_smt {
local smt="$1"
mkdir -p "${HOME}/.local/bin"
loud curl "http://goto.ucsd.edu/~gridaphobe/$smt" -o "${HOME}/.local/bin/$smt"
loud chmod a+x "${HOME}/.local/bin/$smt"
}
function install_stack {
local stack_version="$1"
mkdir -p "${HOME}/.local/bin"
mkdir -p '/tmp/stack'
pushd '/tmp/stack'
local dir_name="stack-${stack_version}-x86_64-linux"
local archive_name="${dir_name}.tar.gz"
local stack_url="https://github.com/commercialhaskell/stack/releases/download/v${stack_version}/${archive_name}"
loud wget "${stack_url}"
loud tar -xzvf "./${archive_name}"
loud cp "./${dir_name}/stack" "${HOME}/.local/bin/stack"
loud chmod a+x "${HOME}/.local/bin/stack"
popd
}
function configure_stack {
local ghc_version="$1"
echo "Configuring stack.yaml for ${ghc_version}..."
cat << EOF > 'stack.yaml'
resolver: ${ghc_version}
packages:
- ./liquid-fixpoint
- .
EOF
loud cat stack.yaml
}
function setup_ghc {
loud stack setup
loud stack ghc -- --version
}
function install_dependencies {
echo "Solving dependency constraints..."
loud stack update
loud stack solver --update-config
echo "Installing dependencies..."
loud stack build liquidhaskell --only-dependencies --test --no-run-tests --no-haddock-deps
}
## Building & Testing Stages
function do_build {
loud stack build liquidhaskell --test --no-run-tests --haddock --no-haddock-deps --flag liquidhaskell:devel
}
function do_test {
local tests="$1"
local smt="$2"
local test_runner="$(stack path --dist-dir)/build/test/test"
loud prevent_timeout stack exec -- "${test_runner}" --pattern "$tests/" --smtsolver "$smt" -j2 +RTS -N2 -RTS
}
function dump_fail_logs {
find tests/logs/cur -type f -name '*log.fail' -print0 | while IFS= read -r -d $'\0' file; do
echo "${file}:"
echo " $(pastebin < "${file}")"
done
}
## Run Test Stage
stage="$1"
shift
$stage "$@"