diff --git a/.travis.yml b/.travis.yml index 1c602f566..492422619 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,14 +26,7 @@ jobs: script: - python build_precice.py --dockerfile precice/Dockerfile.Arch --docker-username $DOCKER_USERNAME - python push.py --precice precice/Dockerfile.Arch - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_precice.py --dockerfile precice/Dockerfile.Arch --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_precice.py --dockerfile precice/Dockerfile.Arch --docker-username $DOCKER_USERNAME - stage: Building preCICE name: "Ubuntu 16.04 home" @@ -41,14 +34,7 @@ jobs: script: - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home --docker-username $DOCKER_USERNAME - python push.py --precice precice/Dockerfile.Ubuntu1604.home - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home --docker-username $DOCKER_USERNAME - stage: Building preCICE name: "Ubuntu 16.04 home PETSc [Job failure permitted]" @@ -56,14 +42,7 @@ jobs: script: - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home --petsc yes --docker-username $DOCKER_USERNAME - python push.py --precice precice/Dockerfile.Ubuntu1604.home - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home --petsc yes --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home --petsc yes --docker-username $DOCKER_USERNAME - stage: Building preCICE name: "Ubuntu 16.04.sudo" @@ -71,14 +50,7 @@ jobs: script: - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.sudo --docker-username $DOCKER_USERNAME - python push.py --precice precice/Dockerfile.Ubuntu1604.sudo - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.sudo --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.sudo --docker-username $DOCKER_USERNAME - stage: Building preCICE name: "Ubuntu 18.04.home" @@ -86,14 +58,7 @@ jobs: script: - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.home --docker-username $DOCKER_USERNAME - python push.py --precice precice/Dockerfile.Ubuntu1804.home - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.home --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.home --docker-username $DOCKER_USERNAME - stage: Building preCICE name: "Ubuntu 18.04.sudo" @@ -101,14 +66,7 @@ jobs: script: - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo --docker-username $DOCKER_USERNAME - python push.py --precice precice/Dockerfile.Ubuntu1804.sudo - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo --docker-username $DOCKER_USERNAME - stage: Building preCICE name: "Ubuntu 18.04.sudo.mpich [Job failure permitted]" @@ -116,14 +74,7 @@ jobs: script: - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo.mpich --docker-username $DOCKER_USERNAME - python push.py --precice precice/Dockerfile.Ubuntu1804.sudo.mpich - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo.mpich --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo.mpich --docker-username $DOCKER_USERNAME - stage: Building preCICE name: "Ubuntu 18.04.package" @@ -131,14 +82,7 @@ jobs: script: - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.package --docker-username $DOCKER_USERNAME - python push.py --precice precice/Dockerfile.Ubuntu1804.package - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.package --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.package --docker-username $DOCKER_USERNAME - name: "[Build preCICE on fork] Using cached version" if: fork = true @@ -152,125 +96,62 @@ jobs: script: - python build_adapter.py --dockerfile adapters/Dockerfile.su2-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME - python push.py --adapter adapters/Dockerfile.su2-adapter - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_adapter.py --dockerfile adapters/Dockerfile.su2-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_adapter.py --dockerfile adapters/Dockerfile.su2-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME - name: "[16.04] CalculiX adapter" if: fork = false script: - python build_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME - python push.py --adapter adapters/Dockerfile.calculix-adapter - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME - name: "[16.04] deal.ii adapter" if: fork = false script: - python build_adapter.py --dockerfile adapters/Dockerfile.dealii-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME - python push.py --adapter adapters/Dockerfile.dealii-adapter - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_adapter.py --dockerfile adapters/Dockerfile.dealii-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_adapter.py --dockerfile adapters/Dockerfile.dealii-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME - name: "[16.04] OpenFOAM adapter" if: fork = false script: - python build_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME - python push.py --adapter adapters/Dockerfile.openfoam-adapter - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home --docker-username $DOCKER_USERNAME - name: "[18.04] OpenFOAM adapter" if: fork = false script: - python build_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter.Ubuntu1804 --operating-system ubuntu1804 --precice-installation home --docker-username $DOCKER_USERNAME - python push.py --adapter adapters/Dockerfile.openfoam-adapter.Ubuntu1804 - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter.Ubuntu1804 --operating-system ubuntu1804 --precice-installation home --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter.Ubuntu1804 --operating-system ubuntu1804 --precice-installation home --docker-username $DOCKER_USERNAME - name: "[18.04] FEniCS adapter" if: fork = false script: - python build_adapter.py --dockerfile adapters/Dockerfile.fenics-adapter --operating-system ubuntu1804 --precice-installation home --docker-username $DOCKER_USERNAME - python push.py --adapter adapters/Dockerfile.fenics-adapter - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_adapter.py --dockerfile adapters/Dockerfile.fenics-adapter --operating-system ubuntu1804 --precice-installation home --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_adapter.py --dockerfile adapters/Dockerfile.fenics-adapter --operating-system ubuntu1804 --precice-installation home --docker-username $DOCKER_USERNAME - name: "[18.04] Code_Aster adapter" if: fork = false script: - python build_adapter.py --dockerfile adapters/Dockerfile.codeaster-adapter --operating-system ubuntu1804 --precice-installation home --docker-username $DOCKER_USERNAME - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_adapter.py --dockerfile adapters/Dockerfile.codeaster-adapter --operating-system ubuntu1804 --precice-installation home --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_adapter.py --dockerfile adapters/Dockerfile.codeaster-adapter --operating-system ubuntu1804 --precice-installation home --docker-username $DOCKER_USERNAME - name: "[16.04] OpenFOAM adapter [PETSc] [Job failure permitted]" if: fork = false script: - python build_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes --docker-username $DOCKER_USERNAME - python push.py --adapter adapters/Dockerfile.openfoam-adapter - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes --docker-username $DOCKER_USERNAME - name: "[16.04] CalculiX adapter [PETSc] [Job failure permitted]" if: fork = false script: - python build_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes --docker-username $DOCKER_USERNAME - python push.py --adapter adapters/Dockerfile.calculix-adapter - deploy: - skip_cleanup: true - provider: script - on: - all_branches: true - script: >- - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && - python push_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes --docker-username $DOCKER_USERNAME + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && python push_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes --docker-username $DOCKER_USERNAME - name: "[Build adapters on fork] Using cached version" diff --git a/push_adapter.py b/push_adapter.py index 0f843a85e..bd4547bfa 100644 --- a/push_adapter.py +++ b/push_adapter.py @@ -1,7 +1,7 @@ import argparse, docker import system_testing import os - + if __name__ == "__main__": # Parsing flags parser = argparse.ArgumentParser(description='Push local adapter image to Docker Hub.') @@ -31,6 +31,15 @@ tag = system_testing.compose_tag(args.docker_username, adapter_name, features, args.branch) + # TravisCI dependent behaviour: + # - If $TRAVIS_TEST_RESULT exists (i.e. we are running in a TravisCI job), + # then check if errors occured while building the image. This is indicated + # by TRAVIS_TEST_RESULT being equal to 1. We then abort the push. + # - If it doesn't, ignore this check and push image normally. + if "TRAVIS_TEST_RESULT" in os.environ: + if os.environ["TRAVIS_TEST_RESULT"] == '1': + print("The TravisCI script failed at a previous command! No image will be pushed.") + exit(1) + docker.push_image(tag=tag, namespace="") - diff --git a/push_precice.py b/push_precice.py index b2bba3dcd..0b08f816b 100644 --- a/push_precice.py +++ b/push_precice.py @@ -1,7 +1,7 @@ import argparse, docker import system_testing import os - + if __name__ == "__main__": # Parsing flags parser = argparse.ArgumentParser(description='Build local preCICE image to Docker Hub.') @@ -34,6 +34,16 @@ features["petsc"] = "yes" tag = system_testing.compose_tag(args.docker_username, "precice", features, args.branch) + + # TravisCI dependent behaviour: + # - If $TRAVIS_TEST_RESULT exists (i.e. we are running in a TravisCI job), + # then check if errors occured while building the image. This is indicated + # by TRAVIS_TEST_RESULT being equal to 1. We then abort the push. + # - If it doesn't, ignore this check and push image normally. + if "TRAVIS_TEST_RESULT" in os.environ: + if os.environ["TRAVIS_TEST_RESULT"] == '1': + print("The TravisCI script failed at a previous command! No image will be pushed.") + exit(1) + docker.push_image(tag=tag, namespace="") - diff --git a/system_testing.py b/system_testing.py index 0f6224cc6..18c885f9e 100644 --- a/system_testing.py +++ b/system_testing.py @@ -222,11 +222,7 @@ def compose_tag(docker_username, base, features, branch): parser.add_argument('-l', '--local', action='store_true', help="Use local preCICE image (default: use remote image)") parser.add_argument('-s', '--systemtest', type=str, help="Choose system tests you want to use", choices = common.get_tests(), required = True) - parser.add_argument('-b', '--branch', help="preCICE branch to use", default="develop") # make sure that branch corresponding to system tests branch is used, if no branch is explicitly specified. If we are testing a pull request, will test against develop by default. -# Usage of the branch argument: -# When on a PR, this will by default use the develop versions of preCICE and adapter images. -# This makes it easier to experiment with tests, which are most commonly addressed by PRs -# (otherwise you would need to also create preCICE and adapter images for your branch which are only different in name) + parser.add_argument('-b', '--branch', help="preCICE branch to use", default=os.environ["TRAVIS_BRANCH"] if ("TRAVIS_BRANCH" in os.environ and os.environ["TRAVIS_PULL_REQUEST"] == "false") else (os.environ["TRAVIS_PULL_REQUEST_BRANCH"] if ("TRAVIS_PULL_REQUEST_BRANCH" in os.environ) else "develop")) # make sure that branch corresponding to system tests branch is used, if no branch is explicitly specified. If we are testing a pull request, make sure to test agains branch from which PR originated. parser.add_argument('-f', '--force_rebuild', nargs='+', help="Force rebuild of variable parts of docker image", default = [], choices = ["precice", "tests"]) parser.add_argument('--base', type=str,help="Base preCICE image to use", diff --git a/trigger_systemtests.py b/trigger_systemtests.py index 4594f8627..a467be420 100644 --- a/trigger_systemtests.py +++ b/trigger_systemtests.py @@ -287,7 +287,7 @@ def generate_failure_callback(): parser.add_argument('--st-branch', type=str, help="Used branch of systemtests", default='develop' ) parser.add_argument('--adapter', type=str, help="Adapter for which you want to trigger systemtests", required=True, choices = adapters_info.keys() ) - parser.add_argument('--output', help="Enable output for the triggered tests", action='store_true') + parser.add_argument('-o', '--output', help="Enable output for the triggered tests", action='store_true') parser.add_argument('--failure', help="Whether to trigger normal or failure build", action="store_true") parser.add_argument('--wait', help='Whether exit only when the triggered build succeeds',