Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhanced travis build setup #33

Merged
merged 1 commit into from
Mar 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 17 additions & 37 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
118 changes: 118 additions & 0 deletions test/src/travis-dep-builder.sh
Original file line number Diff line number Diff line change
@@ -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


14 changes: 14 additions & 0 deletions test/src/travis-run-test.sh
Original file line number Diff line number Diff line change
@@ -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'