forked from ocaml/opam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis-ci.sh
executable file
·131 lines (115 loc) · 3.89 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
#!/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 () {
export OPAMROOT="$OPAMBSROOT"
opam init --yes --no-setup --compiler=$OCAML_VERSION
eval $(opam config env)
if [ "$OPAM_TEST" = "1" ]; then
opam pin add jbuilder --dev-repo --yes
opam install ocamlfind ocamlbuild cohttp cohttp-lwt-unix 'lwt>=3.1.0' ssl cmdliner dose3 opam-file-format re 'jbuilder>=1.0+beta14' 'mccs>=1.1+4' --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
fi
rm -f "$OPAMBSROOT"/log/*
}
case "$TARGET" in
prepare)
mkdir -p ~/local/bin
if [ "$COLD" = "1" ]; 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 ..
make compiler
else
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
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
fi
exit 0
;;
install)
if [ "$COLD" = "1" ]; then
make lib-pkg
else
# 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
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
if [ "$COLD" != "1" ]; then
export OPAMROOT="$OPAMBSROOT"
eval $(opam config env)
[ "$(ocaml -vnum)" = "$OCAML_VERSION" ] || exit 12
fi
./configure --prefix ~/local --with-mccs
if [ "$OPAM_TEST" != "1" -a "$COLD" != "1" ]; then make lib-ext; fi
make all
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 tests ||
(tail -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" = "1" ]; then
cd ~/build/opam-rt-*
OPAMEXTERNALSOLVER="$EXTERNAL_SOLVER" make KINDS="local git" run
else
if [ "$COLD" = "1" ]; then
export PATH=`pwd`/bootstrap/ocaml/bin:$PATH
else
export PATH="$OPAMBSROOT/$OCAML_VERSION/bin":$PATH
fi
# Test basic actions
opam init --bare
opam switch create default ocaml-system
# eval $(opam config env)
opam install lwt
opam list
opam config report
fi
)