From 13ac8218b034caeb6f07c63437f27ca2c5629aa5 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Mon, 30 Sep 2019 18:29:46 +0200 Subject: [PATCH 1/6] Travis: build carl-parser as dependency --- travis/build-helper.sh | 26 +++++++++++++++++++++++--- travis/build.sh | 15 ++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/travis/build-helper.sh b/travis/build-helper.sh index 328140b..f6a9e41 100755 --- a/travis/build-helper.sh +++ b/travis/build-helper.sh @@ -11,11 +11,25 @@ travis_fold() { # Helper for building and testing run() { + + # 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 + travis_fold start virtualenv virtualenv --python=$PYTHON stormpy-env source stormpy-env/bin/activate # Print version python --version + travis_fold end virtualenv # Build pycarl travis_fold start build_pycarl @@ -29,8 +43,8 @@ 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 @@ -46,13 +60,13 @@ run() { # Perform task case $TASK in - Test) + Test*) # Run tests set +e python setup.py test ;; - Documentation) + Documentation*) # Generate documentation pip install sphinx sphinx_bootstrap_theme cd doc @@ -72,4 +86,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; From 59ab38c1ea7c5088fafaa53911d1dc24098b5159 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Mon, 30 Sep 2019 18:31:12 +0200 Subject: [PATCH 2/6] Travis: deploy to Docker Hub --- .travis.yml | 8 +++++++ travis/deploy_docker.sh | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100755 travis/deploy_docker.sh diff --git a/.travis.yml b/.travis.yml index d4133ea..a923ce0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,12 +31,20 @@ jobs: env: TASK=Test 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 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/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 From 583d00012e75b0739df93c06fd957a102e1bb9d7 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Mon, 30 Sep 2019 20:31:45 +0200 Subject: [PATCH 3/6] Fixed loading of build config --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) From ca5d9010525d324d41b6828a94e6787f5e03bc7d Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Mon, 30 Sep 2019 21:26:19 +0200 Subject: [PATCH 4/6] Travis: allow multiple tasks --- .travis.yml | 4 ++-- travis/build-helper.sh | 18 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index a923ce0..01b069e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ 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: @@ -38,7 +38,7 @@ jobs: # 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: diff --git a/travis/build-helper.sh b/travis/build-helper.sh index f6a9e41..5d407b9 100755 --- a/travis/build-helper.sh +++ b/travis/build-helper.sh @@ -58,27 +58,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 } From 71e8e3f569a42913ef463b482f7f450b00292162 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Tue, 1 Oct 2019 13:49:25 +0200 Subject: [PATCH 5/6] Travis: consistent naming of virtual environment --- travis/build-helper.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/travis/build-helper.sh b/travis/build-helper.sh index 5d407b9..5462a60 100755 --- a/travis/build-helper.sh +++ b/travis/build-helper.sh @@ -25,8 +25,8 @@ run() { # Create virtual environment travis_fold start virtualenv - virtualenv --python=$PYTHON stormpy-env - source stormpy-env/bin/activate + virtualenv --python=$PYTHON venv + source venv/bin/activate # Print version python --version travis_fold end virtualenv From c05c08baa32bf5f110d0bd78db4f022cf02b5f76 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Wed, 2 Oct 2019 12:56:30 +0200 Subject: [PATCH 6/6] Travis: fix directories --- travis/build-helper.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/travis/build-helper.sh b/travis/build-helper.sh index 5462a60..a566447 100755 --- a/travis/build-helper.sh +++ b/travis/build-helper.sh @@ -11,6 +11,8 @@ travis_fold() { # Helper for building and testing run() { + # We start in /opt/stormpy + cd .. # Build carl-parser travis_fold start build_carl_parser @@ -48,6 +50,7 @@ run() { # 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