Permalink
Browse files

An attempt to refactor travis scripts and use caching

  • Loading branch information...
1 parent 2688a18 commit fda673f8ab905b4310e59d04d6884dc0ba0003c2 @AltGr AltGr committed Oct 17, 2016
Showing with 64 additions and 54 deletions.
  1. +44 −53 .travis-ci.sh
  2. +20 −1 .travis.yml
View
@@ -1,50 +1,33 @@
-# Git should be configured properely to run the tests
-git config --global user.email "travis@example.com"
-git config --global user.name "Travis CI"
-
-install_on_linux () {
- # Install OCaml PPAs
- case "$OCAML_VERSION" in
- 3.12.1) ppa=avsm/ocaml312+opam12 ;;
- 4.00.1) ppa=avsm/ocaml40+opam12 ;;
- 4.01.0) ppa=avsm/ocaml41+opam12 ;;
- 4.02.3) ppa=avsm/ocaml42+opam12 ;;
- 4.03.0) ppa=avsm/ocaml43+opam12 ;;
- *) echo Unknown $OCAML_VERSION; exit 1 ;;
- esac
-
- echo "yes" | sudo add-apt-repository ppa:$ppa
- sudo apt-get update -qq
- sudo apt-get install -qq ocaml ocaml-native-compilers time $EXTERNAL_SOLVER ${OPAM_TEST:+opam}
-}
-
-install_on_osx () {
- curl -OL "http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.6.dmg"
- sudo hdiutil attach XQuartz-2.7.6.dmg
- sudo installer -verbose -pkg /Volumes/XQuartz-2.7.6/XQuartz.pkg -target /
- case "$OCAML_VERSION" in
- 4.03.0) brew update; brew install ocaml;;
-# 4.03.0) brew update; brew install ocaml --HEAD ;;
- *) echo Skipping $OCAML_VERSION on OSX; exit 0 ;;
- esac
- if [ -n "$EXTERNAL_SOLVER$OPAM_TEST" ]; then
- brew install $EXTERNAL_SOLVER ${OPAM_TEST:+opam}
- fi
-}
-
-source_branch_name () {
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
- echo $TRAVIS_BRANCH
- else
- curl -s https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST | sed -n '/^ *"head":/ { :loop; s/^ *"ref": "\(.*\)",/\1/p; t quit; n; b loop; :quit }'
- fi
-}
-
-case $TRAVIS_OS_NAME in
-osx) install_on_osx ;;
-linux) install_on_linux ;;
+#!/bin/bash -xue
+
+OPAMBSVERSION=1.2.2
+OPAMBSROOT=$HOME/.opam.bootstrap
+PATH=~/local/bin:$PATH; export PATH
+
+TARGET="$1"; shift
+
+case "$TARGET" in
+ prepare)
+ mkdir -p ~/local/bin
+ wget -q -O ~/local/bin/opam \
+ "https://github.com/ocaml/opam/releases/download/opam-$OPAMBSVERSION-$(uname -m)-$(uname -s)"
+ exit 0
+ ;;
+ install)
+ opam init --root=$OPAMBSROOT --yes --no-setup --compiler=$OCAML_VERSION
+ if [ "$OPAM_TEST" = "1" ]; then
+ opam install --root=$OPAMBSROOT ocamlfind lwt.2.5.2 cohttp.0.20.2 ssl cmdliner dose.3.3 jsonm
+ fi
+ exit 0
+ ;;
+ build)
+ ;;
+ *)
+ echo "bad command $TARGET"; exit 1
esac
+eval $(opam config env --root=$OPAMBSROOT)
+
OCAMLV=$(ocaml -vnum)
echo === OCaml version $OCAMLV ===
if [ "$OCAMLV" != "$OCAML_VERSION" ]; then
@@ -55,25 +38,28 @@ fi
export OPAMYES=1
export OCAMLRUNPARAM=b
+
if [ "$OPAM_TEST" = "1" ]; then
# Compile OPAM using the system libraries (install them using OPAM)
# ignore the warnings
echo "Bootstrapping for opam with:"
opam config report
- opam init
-
eval `opam config env`
- opam install ocamlfind lwt.2.5.2 cohttp.0.20.2 ssl cmdliner dose.3.3 jsonm
- ./configure
+
+ ./configure --prefix ~/local
+
make
- # overwrite the previous install of OPAM with the new binary
- # and libraries
- sudo make install
+ make install
+
+ # Reset the bootstrapping opam root
+ eval $(opam config env --root ~/.opam)
+
make libinstall prefix=$(opam config var prefix)
+
# Compile and run opam-rt
- wget https://github.com/ocaml/opam-rt/archive/$(source_branch_name).tar.gz -O opam-rt.tar.gz || \
+ 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-*
@@ -85,6 +71,11 @@ else
make lib-ext
make
make opam-check
+
+ # Git should be configured properly to run the tests
+ git config --global user.email "travis@example.com"
+ git config --global user.name "Travis CI"
+
make tests > tests.log 2>&1 || (tail -1000 tests.log && exit 1)
# Let's see basic tasks works
sudo make install
View
@@ -1,5 +1,24 @@
language: c
-script: bash -ex .travis-ci.sh
+sudo: required
+dist: trusty
+
+addons:
+ apt:
+ packages:
+ - aspcud
+
+before_install:
+ - bash -ex .travis-ci.sh prepare
+install:
+ - bash -ex .travis-ci.sh install
+
+cache:
+ directories:
+ - $HOME/.opam.bootstrap
+
+script:
+ - bash -ex .travis-ci.sh build
+
matrix:
include:
- os: linux

0 comments on commit fda673f

Please sign in to comment.