From d62afb248be3083c46a2b6f80489e9da4bef5e28 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Mon, 3 Jul 2017 17:44:17 +0200 Subject: [PATCH] Started on travis for stormpy --- .travis.yml | 34 ++++++++++++++++++++++ travis/build-helper.sh | 61 +++++++++++++++++++++++++++++++++++++++ travis/build.sh | 42 +++++++++++++++++++++++++++ travis/install_linux.sh | 5 ++++ travis/install_osx.sh | 63 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 .travis.yml create mode 100755 travis/build-helper.sh create mode 100755 travis/build.sh create mode 100755 travis/install_linux.sh create mode 100755 travis/install_osx.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..86a4ca3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,34 @@ +# +# General config +# +branches: + only: + - master +dist: trusty +language: generic + +# Enable docker support +services: +- docker +sudo: required + +notifications: + email: + on_failure: always + on_success: change + recipients: + - secure: "QEKHoyya6CiCt2C8d2TupExTUy24tb8JxYUGVgBm2vqcWaEMuOpVbGeSFUJ9DVsg7VGDcL7rTFGjAJ+AlQLpRP+QKdHidECqbBn17P6koIuSrGuE9Q9VX9GEDiutYjWN8ex2Vx/tgzW7eVV71YdkWfwbnjbXTw4Uf4KqF91yoMLvubAJCaRqjrmnlyd4TWZmi+jxVHaev6OjJ82j1lCKWqNd11PpQMVWMyKE0AqX87P6fcnm5lFgV/8sK++pOR+j4eJpKeZfaUBa7PxFVIKEzEwjU3B9CKy59Mv5+omLm+56zoiLFy+2kBzdJZN96c/V4gcbO3qwItRixromj8mi0PcldAT2pvEmg50Z6/HHhVIRBiiqJo2CvAwUfp/UCRccx03GJPvzLol/DomArvVWiXHhf5HeNcgMTJ0eeeBZh35KITcltaZpR4+Zdxv+sy/M1AH3Ia0NFPcDZ8+XcR1dZUvNWs14J57gVkzocxDyXVL5CmL07qeyj9eUKLyvWer08TbY1XPpYQBxq9EuV4ZplhEYsHg0c6bMAc7PQIMWmaiVNCuzFb/ws/eTF7MUmbYoMHU3Veva/pf0HQESyoMucA+zXDk5MWJ6VRnYtVRMRdLtsfod9dSfgMNUi+TXNb3ZxjG1KNa9SnvBK+9RJ3hTnpIm9vN7lw84lxv1joElmUw=" + - secure: "V+e+fWWLx/SmFeseTdMvtdu3l/jFUH1SuOXYQXxyXeHcyofp/plxT5k+3ZWuCm2w3o9J9zSXo8qSFlcUR0KkSOi6moj5ki8mPjiKPbVQEnrXprZ7eVIPf1n9XF2LEON0BIlrh+PbDK5nRtPiW80nbg5UXFO+SnQr5YQgS49VPMqRIP7waIxG5Ha5AEjLXJocbPi0kFD1YBMSaL5mZ3EiGn4edXwdGjDvDhT2mw2gUlD3DQiT8MCpL6Tymt9sMK2fekhcyq7Vx4j1sDzz4X2KQZ0VpYfX+LgqtzmmJl9sd4is90tk5xV2hoxpoEePAUOg3409As0ZwadSgIrU6jLRB8TBZxZB9dcVwp++ZvjmFaHRkBr+p1rQKiiDU+K4SVWrzOtYKsKnhA8bu6TxBxfV7RQ9VPgei7JNJwjhDasWqyoASc6F8/6N03XnDsumZDiGoW6VJh9Ll3gszwqGb/+N1q9zAt1DrQSgI5BYkTjKqqavfxbxzL6ZCYl8ifu6259w45zWVygfhntT7Oe+TB9Sk3Yf9bT+XOIYPkqREFUUEi+DJtvokfJZzL1dVDrbod0vPa4rnmUdKIA2sNjlompb9d3toJlVTprJiDD2fV5DNWk4XYLxG8QvDSUUQY16BfRx2RVbG68kZzXCASdws8JeArI/FZwxyUyohv+9V4namuY=" + +# +# Configurations +# +jobs: + include: + # docker storm:latest + - os: linux + compiler: gcc + env: TASK=Test DOCKER=latest PYTHON=python3 + install: travis/install_linux.sh + script: travis/build.sh + diff --git a/travis/build-helper.sh b/travis/build-helper.sh new file mode 100755 index 0000000..8b9ff90 --- /dev/null +++ b/travis/build-helper.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +set -e + +# Helper for travis folding +travis_fold() { + local action=$1 + local name=$2 + echo -en "travis_fold:${action}:${name}\r" +} + +# Helper for building and testing +run() { + # Create virtual environment + virtualenv --python=$PYTHON stormpy-env + source stormpy-env/bin/activate + # Print version + python --version + + # Build pycarl + travis_fold start build_pycarl + git clone https://github.com/moves-rwth/pycarl.git + cd pycarl + python setup.py build_ext -j 1 develop + travis_fold end build_pycarl + cd .. + + # Build stormpy + travis_fold start build_stormpy + python setup.py build_ext -j 1 develop + travis_fold end build_stormpy + + # Perform task + case $TASK in + Test) + # Run tests + set +e + python -m pytest -sv tests/ + ;; + + Documentation) + # Generate documentation + pip install sphinx + cd doc + make html + touch build/html/.nojekyll + rm -r build/html/_sources + ;; + + *) + echo "Unrecognized value of TASK: $TASK" + exit 1 + esac +} + + +# This only exists in OS X, but it doesn't cause issues in Linux (the dir doesn't exist, so it's +# ignored). +export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" + +run diff --git a/travis/build.sh b/travis/build.sh new file mode 100755 index 0000000..0e9ad93 --- /dev/null +++ b/travis/build.sh @@ -0,0 +1,42 @@ +#!/bin/bash -x + +N_JOBS=2 + +OS=$TRAVIS_OS_NAME + +case $OS in +linux) + # Execute docker image on Linux + # Stop previous session + docker rm -f stormpy &>/dev/null + # Run container + set -e + docker run -d -it --name stormpy --privileged mvolk/storm:$DOCKER + # Copy local content into container + docker exec stormpy mkdir opt/stormpy + docker cp . stormpy:/opt/stormpy + # Install virtualenv + docker exec stormpy apt-get install -qq -y python python3 virtualenv + set +e + + # Execute main process + docker exec stormpy bash -c " + export N_JOBS=$N_JOBS; + export OS=$OS; + export PYTHON=$PYTHON; + export TASK=$TASK; + cd opt/stormpy; + travis/build-helper.sh" + exit $? + ;; + +osx) + echo "MacOS currently unsupported" + exit 1 + ;; + +*) + # Other OS + echo "Unsupported OS: $OS" + exit 1 +esac diff --git a/travis/install_linux.sh b/travis/install_linux.sh new file mode 100755 index 0000000..911b673 --- /dev/null +++ b/travis/install_linux.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +sudo apt-get install -qq -y docker diff --git a/travis/install_osx.sh b/travis/install_osx.sh new file mode 100755 index 0000000..b7cec33 --- /dev/null +++ b/travis/install_osx.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# Script installing dependencies +# Inspired by https://github.com/google/fruit + +set -e + +# Helper for travis folding +travis_fold() { + local action=$1 + local name=$2 + echo -en "travis_fold:${action}:${name}\r" +} + +# Helper for installing packages via homebrew +install_brew_package() { + if brew list -1 | grep -q "^$1\$"; then + # Package is installed, upgrade if needed + brew outdated "$1" || brew upgrade "$@" + else + # Package not installed yet, install. + # If there are conflicts, try overwriting the files (these are in /usr/local anyway so it should be ok). + brew install "$@" || brew link --overwrite gcc49 + fi +} + +# Update packages +travis_fold start brew_update +brew update +travis_fold end brew_update + +travis_fold start brew_install_util +# For md5sum +install_brew_package md5sha1sum +# For `timeout' +install_brew_package coreutils + +which cmake &>/dev/null || install_brew_package cmake + +# Install compiler +case "${COMPILER}" in +gcc-4.8) install_brew_package gcc@4.8 ;; +gcc-4.9) install_brew_package gcc@4.9 ;; +gcc-5) install_brew_package gcc@5 ;; +gcc-6) install_brew_package gcc@6 ;; +clang-default) ;; +clang-3.7) install_brew_package llvm@3.7 --with-clang --with-libcxx;; +clang-3.8) install_brew_package llvm@3.8 --with-clang --with-libcxx;; +clang-3.9) install_brew_package llvm@3.9 --with-clang --with-libcxx;; +clang-4.0) install_brew_package llvm --with-clang --with-libcxx;; +*) echo "Compiler not supported: ${COMPILER}. See travis/install_osx.sh"; exit 1 ;; +esac +travis_fold end brew_install_util + + +# Install dependencies +travis_fold start brew_install_dependencies +install_brew_package gmp --c++11 +install_brew_package cln +install_brew_package ginac +install_brew_package boost --c++11 +install_brew_package python +install_brew_package python3 +travis_fold end brew_install_dependencies