From 2295202aa47faa4f442ffc42b1efe5a7f953bff5 Mon Sep 17 00:00:00 2001 From: Greg Lee Date: Fri, 17 Mar 2017 08:14:55 -0700 Subject: [PATCH] enhanced travis build setup --- .travis.yml | 54 +++++---------- test/src/travis-dep-builder.sh | 118 +++++++++++++++++++++++++++++++++ test/src/travis-run-test.sh | 14 ++++ 3 files changed, 149 insertions(+), 37 deletions(-) create mode 100755 test/src/travis-dep-builder.sh create mode 100755 test/src/travis-run-test.sh diff --git a/.travis.yml b/.travis.yml index 11feaa9..0c3376a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,18 @@ language: c cache: directories: - - $HOME/openmpi-gcc - - $HOME/openmpi-clang + - $HOME/local sudo: required -compiler: - - gcc - - clang +matrix: + include: + - compiler: gcc + env: + - compiler: gcc + env: T_INSTALL=t ARGS=--with-test-installed + - compiler: clang + env: CC=clang CXX=clang++ addons: apt: @@ -19,38 +23,14 @@ addons: - libboost-dev - munge -env: - global: - - export PATH=./:$HOME/openmpi/bin:$PATH - - export LD_LIBRARY_PATH=$HOME/openmpi/lib:$LD_LIBRARY_PATH - -install: - # This should all be cached, so only run commands below when we want to update the cache -# - export VERBOSE=1 -# - export V=1 -# # Download and install OpenMPI v2.0.2 -# - pushd $HOME/build -# - wget https://www.open-mpi.org/software/ompi/v2.0/downloads/openmpi-2.0.2.tar.gz -# - tar xf openmpi-2.0.2.tar.gz -# - cd openmpi-2.0.2 -# - ./configure --prefix=$HOME/openmpi-$CC -# - make && make install -# - popd +before_install: + - eval $(./test/src/travis-dep-builder.sh --printenv) + - ./test/src/travis-dep-builder.sh --cachedir=$HOME/local/.cache script: - - export PATH=./:$HOME/openmpi-$CC/bin:$PATH - - export LD_LIBRARY_PATH=$HOME/openmpi-$CC/lib:$LD_LIBRARY_PATH + - export MAKECMDS="make -j3 && make -j3 check" - ./bootstrap && mkdir build && cd build - - ../configure --prefix=$HOME/local --with-test-rm=orte --with-test-installed --with-test-rm-launcher=$HOME/openmpi-$CC/bin/mpirun --with-test-ncore-per-CN=2 --with-test-nnodes=1 - - make -j3 - - make install - - make -j3 check - - echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope - - cd test/src - - cat test.launch_1 - - ./test.launch_1 - - sleep 60 - - cat test.attach_1 - - ./test.attach_1 - - sleep 60 - - echo 'done' + - if test "$T_INSTALL" = "t" ; then ARGS="$ARGS --prefix=/tmp/lmon"; MAKECMDS="make -j3 && make install && make -j3 check"; fi + - ../configure --with-test-rm=orte $ARGS --with-test-rm-launcher=$HOME/local/bin/mpirun --with-test-ncore-per-CN=2 --with-test-nnodes=1 + - eval ${MAKECMDS} + - if test "$T_INSTALL" = "t"; then ../test/src/travis-run-test.sh; fi diff --git a/test/src/travis-dep-builder.sh b/test/src/travis-dep-builder.sh new file mode 100755 index 0000000..17f1746 --- /dev/null +++ b/test/src/travis-dep-builder.sh @@ -0,0 +1,118 @@ +#!/bin/bash +# +# + +prefix=$HOME/local +cachedir=$HOME/local/.cache + +# +# Ordered list of software to download and install into $prefix. +# NOTE: Code currently assumes .tar.gz suffix... +# +downloads="\ +https://www.open-mpi.org/software/ompi/v2.0/downloads/openmpi-2.0.2.tar.gz" + +declare -A extra_configure_opts=(\ +) + +declare -r prog=${0##*/} +declare -r long_opts="prefix:,cachedir:,verbose,printenv" +declare -r short_opts="vp:c:P" +declare -r usage="\ +\n +Usage: $prog [OPTIONS]\n\ +Download and install to a local prefix (default=$prefix) dependencies\n\ +for building LaunchMON\n\ +\n\ +Options:\n\ + -v, --verbose Be verbose.\n\ + -P, --printenv Print environment variables to stdout\n\ + -c, --cachedir=DIR Check for precompiled dependency cache in DIR\n\ + -e, --max-cache-age=N Expire cache in N days from creation\n\ + -p, --prefix=DIR Install software into prefix\n +" + +die() { echo -e "$prog: $@"; exit 1; } +say() { echo -e "$prog: $@"; } +debug() { test "$verbose" = "t" && say "$@"; } + +GETOPTS=`/usr/bin/getopt -u -o $short_opts -l $long_opts -n $prog -- $@` +if test $? != 0; then + die "$usage" +fi + +eval set -- "$GETOPTS" +while true; do + case "$1" in + -v|--verbose) verbose=t; shift ;; + -c|--cachedir) cachedir="$2"; shift 2 ;; + -e|--max-cache-age) cacheage="$2"; shift 2 ;; + -p|--prefix) prefix="$2"; shift 2 ;; + -P|--printenv) print_env=1; shift ;; + --) shift ; break; ;; + *) die "Invalid option '$1'\n$usage" ;; + esac +done + +print_env () { + echo "export LD_LIBRARY_PATH=${prefix}/lib:$LD_LIBRARY_PATH" + echo "export CPPFLAGS=-I${prefix}/include" + echo "export LDFLAGS=-L${prefix}/lib" + echo "export PATH=${PATH}:${HOME}/local/usr/bin:${HOME}/local/bin" +} + +if test -n "$print_env"; then + print_env + exit 0 +fi + +eval $(print_env) + +sanitize () +{ + # Sanitize cache name + echo $1 | sed 's/[\t /\]/_/g' +} + +check_cache () +{ + test -n "$cachedir" || return 1 + local url=$(sanitize $1) + local cachefile="${cachedir}/${url}" + test -f "${cachefile}" || return 1 + test -n "$cacheage" || return 0 + + local ctime=$(stat -c%Y ${cachefile}) + local maxage=$((${cacheage}*86400)) + test $ctime -gt $maxage && return 1 +} + +add_cache () +{ + test -n "$cachedir" || return 0 + mkdir -p "${cachedir}" && + touch "${cachedir}/$(sanitize ${1})" +} + + +for pkg in $downloads; do + name=$(basename ${pkg} .tar.gz) + if check_cache "$name"; then + say "Using cached version of ${name}" + continue + fi + mkdir -p ${name} || die "Failed to mkdir ${name}" + ( + cd ${name} && + curl -L -O --insecure ${pkg} || die "Failed to download ${pkg}" + tar --strip-components=1 -xf *.tar.gz || die "Failed to un-tar ${name}" + test -x configure || ./autogen.sh + test -x configure && CC=gcc ./configure --prefix=${prefix} \ + ${extra_configure_opts[$name]} || : && + make PREFIX=${prefix} && + make PREFIX=${prefix} install + ) || die "Failed to build and install $name" + add_cache "$name" +done + + diff --git a/test/src/travis-run-test.sh b/test/src/travis-run-test.sh new file mode 100755 index 0000000..fbf195e --- /dev/null +++ b/test/src/travis-run-test.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -ex + +echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope +cd test/src +export PATH=./:$PATH +cat test.launch_1 +./test.launch_1 +sleep 60 +cat test.attach_1 +./test.attach_1 +sleep 60 +echo 'done'