diff --git a/.travis.yml b/.travis.yml index d4133ea..01b069e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,15 +28,23 @@ jobs: # Docker Storm master - os: linux compiler: gcc - env: TASK=Test CONFIG=Release DOCKER=storm:travis PYTHON=python3 + env: TASK=TestDocker CONFIG=Release DOCKER=storm:travis PYTHON=python3 script: travis/build.sh + deploy: + - provider: script + skip_cleanup: true + script: bash travis/deploy_docker.sh stormpy # Docker Storm master in debug mode - os: linux compiler: gcc - env: TASK=Test CONFIG=Debug DOCKER=storm:travis-debug PYTHON=python3 + env: TASK=TestDocker CONFIG=Debug DOCKER=storm:travis-debug PYTHON=python3 script: travis/build.sh + deploy: + - provider: script + skip_cleanup: true + script: bash travis/deploy_docker.sh stormpy # Docker Storm stable - os: linux compiler: gcc diff --git a/setup.py b/setup.py index de75c00..171fc8c 100755 --- a/setup.py +++ b/setup.py @@ -164,8 +164,6 @@ class CMakeBuild(build_ext): def initialize_options(self): build_ext.initialize_options(self) - # Load setup config - self.config.load_from_file("build/build_config.cfg") # Set default values for custom cmdline flags self.storm_dir = None self.disable_dft = None @@ -175,6 +173,9 @@ class CMakeBuild(build_ext): def finalize_options(self): build_ext.finalize_options(self) + # Load setup config + # This can only be done after the finalization step, because otherwise build_temp is not initialized yet. + self.config.load_from_file(os.path.join(self.build_temp, "build_config.cfg")) # Update setup config self.config.update("storm_dir", self.storm_dir) self.config.update("disable_dft", self.disable_dft) diff --git a/travis/build-helper.sh b/travis/build-helper.sh index 328140b..a566447 100755 --- a/travis/build-helper.sh +++ b/travis/build-helper.sh @@ -11,11 +11,27 @@ travis_fold() { # Helper for building and testing run() { + # We start in /opt/stormpy + cd .. + + # Build carl-parser + travis_fold start build_carl_parser + git clone --single-branch -b master14 https://github.com/ths-rwth/carl-parser + cd carl-parser + mkdir build + cd build + cmake .. "${CMAKE_ARGS[@]}" + make carl-parser -j 1 + cd ../.. + travis_fold end build_carl_parser + # Create virtual environment - virtualenv --python=$PYTHON stormpy-env - source stormpy-env/bin/activate + travis_fold start virtualenv + virtualenv --python=$PYTHON venv + source venv/bin/activate # Print version python --version + travis_fold end virtualenv # Build pycarl travis_fold start build_pycarl @@ -29,11 +45,12 @@ run() { python setup.py build_ext -j 1 develop ;; esac - travis_fold end build_pycarl cd .. + travis_fold end build_pycarl # Build stormpy travis_fold start build_stormpy + cd stormpy case "$CONFIG" in Debug*) python setup.py build_ext --storm-dir /opt/storm/build/ --debug -j 1 develop @@ -44,27 +61,23 @@ run() { esac travis_fold end build_stormpy - # Perform task - case $TASK in - Test) + # Perform tasks + if [[ "$TASK" == *Test* ]] + then # Run tests set +e python setup.py test - ;; + fi - Documentation) + if [[ "$TASK" == *Documentation* ]] + then # Generate documentation pip install sphinx sphinx_bootstrap_theme cd doc make html touch build/html/.nojekyll rm -r build/html/_sources - ;; - - *) - echo "Unrecognized value of TASK: $TASK" - exit 1 - esac + fi } @@ -72,4 +85,10 @@ run() { # ignored). export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" +case "$CONFIG" in +Debug*) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG") ;; +Release*) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="$STLARG") ;; +*) echo "Unrecognized value of CONFIG: $CONFIG"; exit 1 ;; +esac + run diff --git a/travis/build.sh b/travis/build.sh index 2bbe2e8..f277324 100755 --- a/travis/build.sh +++ b/travis/build.sh @@ -1,5 +1,12 @@ #!/bin/bash -x +# Helper for travis folding +travis_fold() { + local action=$1 + local name=$2 + echo -en "travis_fold:${action}:${name}\r" +} + N_JOBS=2 OS=$TRAVIS_OS_NAME @@ -15,15 +22,21 @@ linux) # Copy local content into container docker exec stormpy mkdir /opt/stormpy docker cp . stormpy:/opt/stormpy - # Install virtualenv + + travis_fold start install_dependencies docker exec stormpy apt-get update + # Install dependencies for carl-parser + docker exec stormpy apt-get install -qq -y maven uuid-dev + # Install virtualenv docker exec stormpy apt-get install -qq -y python python3 virtualenv + travis_fold end install_dependencies set +e # Execute main process docker exec stormpy bash -c " export N_JOBS=$N_JOBS; export OS=$OS; + export STLARG=; export PYTHON=$PYTHON; export CONFIG=$CONFIG; export TASK=$TASK; diff --git a/travis/deploy_docker.sh b/travis/deploy_docker.sh new file mode 100755 index 0000000..c95d126 --- /dev/null +++ b/travis/deploy_docker.sh @@ -0,0 +1,48 @@ +#!/bin/bash -x + +set -e + +OS=$TRAVIS_OS_NAME + +# Do not deploy if credentials are not given +if [ "${TRAVIS_SECURE_ENV_VARS}" == "false" ]; then + echo "WARNING: Not deploying as no credentials are given." + exit 0; +fi + +# Do not deploy for pull requests +if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then + exit 0; +fi + +echo "Deploying $1 to Dockerhub" + +case $OS in +linux) + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + # Deploy as debug/release + case "$CONFIG" in + *Debug*) + docker commit $1 movesrwth/$1:travis-debug + docker push movesrwth/$1:travis-debug + ;; + *Release*) + docker commit $1 movesrwth/$1:travis + docker push movesrwth/$1:travis + ;; + *) + echo "Unrecognized value of CONFIG: $CONFIG"; exit 1 + ;; + esac + ;; + +osx) + echo "Docker deployment on Mac OSX not used." + exit 1 + ;; + +*) + # Unknown OS + echo "Unsupported OS: $OS" + exit 1 +esac