forked from ocaml/opam
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis-ci.sh
executable file
·98 lines (84 loc) · 2.93 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
#!/bin/bash -xue
OPAMBSVERSION=1.2.2
OPAMBSROOT=$HOME/.opam.bootstrap
PATH=~/local/bin:$PATH; export PATH
TARGET="$1"; shift
# Install the build requirements into $OPAMBSROOT using the opam binary from the
# prepare step
install-bootstrap () {
opam init --root=$OPAMBSROOT --yes --no-setup --compiler=$OCAML_VERSION
eval $(opam config env --root=$OPAMBSROOT)
if [ "$OPAM_TEST" = "1" ]; then
opam install ocamlfind lwt.2.5.2 cohttp.0.20.2 ssl cmdliner dose3 jsonm opam-file-format --yes
# Allow use of ocamlfind packages in ~/local/lib
FINDCONF=$(ocamlfind printconf conf)
sed "s%^path=.*%path=\"$HOME/local/lib:$(opam config var lib)\"%" $FINDCONF >$FINDCONF.1
mv $FINDCONF.1 $FINDCONF
else
opam install ocamlbuild --yes
fi
rm -f "$OPAMBSROOT"/log/*
}
case "$TARGET" in
prepare)
mkdir -p ~/local/bin
wget -q -O ~/local/bin/opam \
"https://github.com/ocaml/opam/releases/download/$OPAMBSVERSION/opam-$OPAMBSVERSION-$(uname -m)-$(uname -s)"
chmod a+x ~/local/bin/opam
exit 0
;;
install)
# Note: this part is cached, and must be idempotent
# Re-init opam from scratch if the install fails
if [ -d $OPAMBSROOT ]
then install-bootstrap || { rm -rf $OPAMBSROOT; install-bootstrap; }
else install-bootstrap
fi
exit 0
;;
build)
;;
*)
echo "bad command $TARGET"; exit 1
esac
export OPAMYES=1
export OCAMLRUNPARAM=b
# Git should be configured properly to run the tests
git config --global user.email "[email protected]"
git config --global user.name "Travis CI"
( # Run subshell in bootstrap root env to build
eval $(opam config env --root=$OPAMBSROOT)
[ "$(ocaml -vnum)" = "$OCAML_VERSION" ] || exit 12
./configure --prefix ~/local
if [ "$OPAM_TEST" != "1" ]; then make lib-ext; fi
make all opam-check
rm -f ~/local/bin/opam
make install
if [ "$OPAM_TEST" = "1" ]; then
make libinstall LIBINSTALL_DIR=$HOME/local/lib
# 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 xvfz opam-rt.tar.gz
cd opam-rt-*
make
else
# Note: these tests require a "system" compiler and will use the one in $OPAMBSROOT
OPAMEXTERNALSOLVER="$EXTERNAL_SOLVER" make -C tests || (tail -2000 tests/fulltest-*.log; exit 1)
fi
)
( # Finally run the tests, in a clean environment
export OPAMKEEPLOGS=1
if [ "$OPAM_TEST" = "1" ]; then
cd ~/build/opam-rt-*
OPAMEXTERNALSOLVER="$EXTERNAL_SOLVER" make KINDS="local git" run
else
# Test basic actions
opam init
eval $(opam config env)
opam install lwt
opam list
opam config report
fi
)