forked from ocaml/opam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis-ci.sh
executable file
·327 lines (299 loc) · 9.52 KB
/
.travis-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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#!/bin/bash -xue
OPAMBSVERSION=2.0.0
OPAMBSROOT=$HOME/.opam.cached
OPAMBSSWITCH=opam-build
PATH=~/local/bin:$PATH; export PATH
TARGET="$1"; shift
COLD=${COLD:-0}
OPAM_TEST=${OPAM_TEST:-0}
EXTERNAL_SOLVER=${EXTERNAL_SOLVER:-}
set +x
echo "TRAVIS_COMMIT_RANGE=$TRAVIS_COMMIT_RANGE"
echo "TRAVIS_COMMIT=$TRAVIS_COMMIT"
if [[ $TRAVIS_EVENT_TYPE = 'pull_request' ]] ; then
FETCH_HEAD=$(git rev-parse FETCH_HEAD)
echo "FETCH_HEAD=$FETCH_HEAD"
else
FETCH_HEAD=$TRAVIS_COMMIT
fi
if [[ $TRAVIS_EVENT_TYPE = 'push' ]] ; then
if ! git cat-file -e "$TRAVIS_COMMIT" 2> /dev/null ; then
echo 'TRAVIS_COMMIT does not exist - CI failure'
exit 1
fi
else
if [[ $TRAVIS_COMMIT != $(git rev-parse FETCH_HEAD) ]] ; then
echo 'WARNING! Travis TRAVIS_COMMIT and FETCH_HEAD do not agree!'
if git cat-file -e "$TRAVIS_COMMIT" 2> /dev/null ; then
echo 'TRAVIS_COMMIT exists, so going with it'
else
echo 'TRAVIS_COMMIT does not exist; setting to FETCH_HEAD'
TRAVIS_COMMIT=$FETCH_HEAD
fi
fi
fi
set -x
init-bootstrap () {
export OPAMROOT=$OPAMBSROOT
# The system compiler will be picked up
opam init --yes --no-setup
eval $(opam env)
opam update
CURRENT_SWITCH=$(opam config var switch)
if [[ $CURRENT_SWITCH != "default" ]] ; then
opam switch default
eval $(opam env)
opam switch remove $CURRENT_SWITCH --yes
fi
if [ "$OPAM_TEST" = "1" ]; then
opam switch create $OPAMBSSWITCH ocaml-system
eval $(opam env)
# extlib is installed, since UChar.cmi causes problems with the search
# order. See also the removal of uChar and uTF8 in src_ext/jbuild-extlib-src
opam install ssl cmdliner dose3 cudf.0.9 opam-file-format re extlib dune 'mccs>=1.1+5' --yes
fi
rm -f "$OPAMBSROOT"/log/*
}
CheckConfigure () {
GIT_INDEX_FILE=tmp-index git read-tree --reset -i "$1"
git diff-tree --diff-filter=d --no-commit-id --name-only -r "$1" \
| (while IFS= read -r path
do
case "$path" in
configure|configure.ac|m4/*)
touch CHECK_CONFIGURE;;
esac
done)
rm -f tmp-index
if [[ -e CHECK_CONFIGURE ]] ; then
echo "configure generation altered in $1"
echo 'Verifying that configure.ac generates configure'
git clean -dfx
git checkout -f "$1"
mv configure configure.ref
make configure
if ! diff -q configure configure.ref >/dev/null ; then
echo -e "[\e[31mERROR\e[0m] configure.ac in $1 doesn't generate configure, \
please run make configure and fixup the commit"
ERROR=1
fi
fi
}
case "$TARGET" in
prepare)
if [ "$TRAVIS_BUILD_STAGE_NAME" = "Hygiene" ] ; then
exit 0
fi
make --version
mkdir -p ~/local/bin
# Git should be configured properly to run the tests
git config --global user.email "[email protected]"
git config --global user.name "Travis CI"
git config --global gc.autoDetach false
# Disable bubblewrap wrapping, it's not available within Docker
cat <<EOF >>~/.opamrc
required-tools: [
["curl" "wget"]
{"A download tool is required, check env variables OPAMCURL or OPAMFETCH"}
"diff"
"patch"
"tar"
"unzip"
]
wrap-build-commands: []
wrap-install-commands: []
wrap-remove-commands: []
EOF
if [[ $COLD -eq 1 ]] ; then
if [ ! -x ~/local/bin/make ] ; then
wget http://ftpmirror.gnu.org/gnu/make/make-4.2.tar.gz
tar -xzf make-4.2.tar.gz
mkdir make-4.2-build
cd make-4.2-build
../make-4.2/configure --prefix ~/local
make
make install
cd ..
fi
else
if [[ $TRAVIS_OS_NAME = "osx" && -n $EXTERNAL_SOLVER ]] ; then
rvm install ruby-2.3.3
rvm --default use 2.3.3
brew install "$EXTERNAL_SOLVER"
fi
if [[ -e ~/local/versions ]] ; then
. ~/local/versions
if [[ $LOCAL_OCAML_VERSION != $OCAML_VERSION ]] ; then
echo "Cached compiler is $LOCAL_OCAML_VERSION; requested $OCAML_VERSION"
echo "Resetting local cache"
rm -rf ~/local
elif [[ ${LOCAL_OPAMBSVERSION:-$OPAMBSVERSION} != $OPAMBSVERSION ]] ; then
echo "Cached opam is $LOCAL_OPAMBSVERSION; requested $OPAMBSVERSION"
echo "Replacement opam will be downloaded"
rm -f ~/local/bin/opam-bootstrap
fi
fi
fi
exit 0
;;
install)
if [ "$TRAVIS_BUILD_STAGE_NAME" = "Hygiene" ] ; then
exit 0
fi
if [[ $COLD -eq 1 ]] ; then
make compiler
make lib-pkg
else
if [[ ! -x ~/local/bin/ocaml ]] ; then
echo -en "travis_fold:start:ocaml\r"
wget http://caml.inria.fr/pub/distrib/ocaml-${OCAML_VERSION%.*}/ocaml-$OCAML_VERSION.tar.gz
tar -xzf ocaml-$OCAML_VERSION.tar.gz
cd ocaml-$OCAML_VERSION
if [[ $OPAM_TEST -ne 1 ]] ; then
CONFIGURE_SWITCHES="-no-ocamldoc"
if [[ "$OCAML_VERSION" != "4.02.3" ]] ; then
CONFIGURE_SWITCHES="$CONFIGURE_SWITCHES -no-ocamlbuild"
fi
fi
./configure --prefix ~/local -no-graph -no-debugger ${CONFIGURE_SWITCHES:-}
if [[ $OPAM_TEST -eq 1 ]] ; then
make -j 4 world.opt
else
make world.opt
fi
make install
echo "LOCAL_OCAML_VERSION=$OCAML_VERSION" > ~/local/versions
echo -en "travis_fold:end:ocaml\r"
fi
if [[ $OPAM_TEST -eq 1 ]] ; then
echo -en "travis_fold:start:opam\r"
if [[ ! -e ~/local/bin/opam-bootstrap ]] ; then
wget -q -O ~/local/bin/opam-bootstrap \
"https://github.com/ocaml/opam/releases/download/$OPAMBSVERSION/opam-$OPAMBSVERSION-$(uname -m)-$(uname -s)"
fi
cp -f ~/local/bin/opam-bootstrap ~/local/bin/opam
chmod a+x ~/local/bin/opam
if [[ -d $OPAMBSROOT ]] ; then
init-bootstrap || { rm -rf $OPAMBSROOT; init-bootstrap; }
else
init-bootstrap
fi
echo -en "travis_fold:end:opam\r"
fi
fi
exit 0
;;
build)
;;
*)
echo "bad command $TARGET"; exit 1
esac
set +x
if [ "$TRAVIS_BUILD_STAGE_NAME" = "Hygiene" ] ; then
ERROR=0
if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ] ; then
TRAVIS_CUR_HEAD=${TRAVIS_COMMIT_RANGE%%...*}
TRAVIS_PR_HEAD=${TRAVIS_COMMIT_RANGE##*...}
DEEPEN=50
while ! git merge-base "$TRAVIS_CUR_HEAD" "$TRAVIS_PR_HEAD" >& /dev/null
do
echo "Deepening $TRAVIS_BRANCH by $DEEPEN commits"
git fetch origin --deepen=$DEEPEN "$TRAVIS_BRANCH"
((DEEPEN*=2))
done
TRAVIS_MERGE_BASE=$(git merge-base "$TRAVIS_CUR_HEAD" "$TRAVIS_PR_HEAD")
if ! git diff "$TRAVIS_MERGE_BASE..$TRAVIS_PR_HEAD" --name-only --exit-code -- shell/install.sh > /dev/null ; then
echo "shell/install.sh updated - checking it"
eval $(grep '^\(VERSION\|TAG\|OPAM_BIN_URL_BASE\)=' shell/install.sh)
echo "TAG = $TAG"
echo "OPAM_BIN_URL_BASE=$OPAM_BIN_URL_BASE"
ARCHES=0
while read -r key sha
do
ARCHES=1
URL="$OPAM_BIN_URL_BASE$TAG/opam-$TAG-$key"
echo "Checking $URL"
check=$(curl -Ls "$URL" | sha512sum | cut -d' ' -f1)
if [ "$check" = "$sha" ] ; then
echo "Checksum as expected ($sha)"
else
echo -e "[\e[31mERROR\e[0m] Checksum downloaded: $check"
echo -e "[\e[31mERROR\e[0m] Checksum install.sh: $sha"
ERROR=1
fi
done < <(sed -ne 's/.*opam-\$TAG-\([^)]*\).*"\([^"]*\)".*/\1 \2/p' shell/install.sh)
if [ $ARCHES -eq 0 ] ; then
echo "[\e[31mERROR\e[0m] No sha512 checksums were detected in shell/install.sh"
echo "That can't be right..."
ERROR=1
fi
fi
fi
if [[ -z $TRAVIS_COMMIT_RANGE ]]
then CheckConfigure "$TRAVIS_COMMIT"
else
if [[ $TRAVIS_EVENT_TYPE = 'pull_request' ]]
then TRAVIS_COMMIT_RANGE=$TRAVIS_MERGE_BASE..$TRAVIS_PULL_REQUEST_SHA
fi
for commit in $(git rev-list "$TRAVIS_COMMIT_RANGE" --reverse)
do
CheckConfigure "$commit"
done
fi
exit $ERROR
fi
set -x
export OPAMYES=1
export OCAMLRUNPARAM=b
( # Run subshell in bootstrap root env to build
if [[ $OPAM_TEST -eq 1 ]] ; then
export OPAMROOT=$OPAMBSROOT
eval $(opam env)
fi
./configure --prefix ~/local --with-mccs
if [[ $OPAM_TEST$COLD -eq 0 ]] ; then
make lib-ext
fi
make all admin
rm -f ~/local/bin/opam
make install
if [ "$OPAM_TEST" = "1" ]; then
make distclean
for pin in core format solver repository state client ; do
opam pin add --kind=path opam-$pin . --yes
done
# Compile and run opam-rt
cd ~/build
wget https://github.com/ocaml/opam-rt/archive/$TRAVIS_PULL_REQUEST_BRANCH.tar.gz -O opam-rt.tar.gz || \
wget https://github.com/ocaml/opam-rt/archive/master.tar.gz -O opam-rt.tar.gz
tar -xzf opam-rt.tar.gz
cd opam-rt-*
opam install ./opam-rt.opam --deps-only -y
make
opam switch default
opam switch remove $OPAMBSSWITCH --yes
else
# Note: these tests require a "system" compiler and will use the one in $OPAMBSROOT
OPAMEXTERNALSOLVER="$EXTERNAL_SOLVER" make tests ||
(tail -n 2000 _build/default/tests/fulltest-*.log; echo "-- TESTS FAILED --"; exit 1)
fi
)
( # Finally run the tests, in a clean environment
export OPAMKEEPLOGS=1
if [[ $OPAM_TEST -eq 1 ]] ; then
cd ~/build/opam-rt-*
OPAMEXTERNALSOLVER="$EXTERNAL_SOLVER" make KINDS="local git" run
else
if [[ $COLD -eq 1 ]] ; then
export PATH=$PWD/bootstrap/ocaml/bin:$PATH
fi
# Test basic actions
opam init --bare default git+https://github.com/ocaml/opam-repository#8be4290a
opam switch create default ocaml-system
eval $(opam env)
opam install lwt
opam list
opam config report
fi
)
rm -f ~/local/bin/opam