#
# General config
#
branches:
  only:
  - master
  - stable
sudo: required
dist: trusty
language: cpp

# Enable caching
cache:
  timeout: 1000
  directories:
  - build
  - travis/mtime_cache

# Enable docker support
services:
- docker

notifications:
  email:
    on_failure: always
    on_success: change
    recipients:
    secure: "Q9CW/PtyWkZwExDrfFFb9n1STGYsRfI6awv1bZHcGwfrDvhpXoMCuF8CwviIfilm7fFJJEoKizTtdRpY0HrOnY/8KY111xrtcFYosxdndv7xbESodIxQOUoIEFCO0mCNHwWYisoi3dAA7H3Yn661EsxluwHjzX5vY0xSbw0n229hlsFz092HwGLSU33zHl7eXpQk+BOFmBTRGlOq9obtDZ17zbHz1oXFZntHK/JDUIYP0b0uq8NvE2jM6CIVdcuSwmIkOhZJoO2L3Py3rBbPci+L2PSK4Smv2UjCPF8KusnOaFIyDB3LcNM9Jqq5ssJMrK/KaO6BiuYrOZXYWZ7KEg3Y/naC8HjOH1dzty+P7oW46sb9F03pTsufqD4R7wcK+9wROTztO6aJPDG/IPH7EWgrBTxqlOkVRwi2eYuQouZpZUW6EMClKbMHMIxCH2S8aOk/r1w2cNwmPEcunnP0nl413x/ByHr4fTPFykPj8pQxIsllYjpdWBRQfDOauKWGzk6LcrFW0qpWP+/aJ2vYu/IoZQMG5lMHbp6Y1Lg09pYm7Q983v3b7D+JvXhOXMyGq91HyPahA2wwKoG1GA4uoZ2I95/IFYNiKkelDd3WTBoFLNF9YFoEJNdCywm1fO2WY4WkyEFBuQcgDA+YpFMJJMxjTbivYk9jvHk2gji//2w="

#
# Configurations
#
jobs:
  include:

    ###
    # Stage: Build Carl
    ###

    # ubuntu-17.10 - DefaultDebugTravis
    - stage: Build Carl
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebugTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build_carl.sh
      after_success:
        - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
        - docker commit carl mvolk/carl:travis-debug;
        - docker push mvolk/carl:travis-debug;
    # ubuntu-17.10 - DefaultReleaseTravis
    - stage: Build Carl
      os: linux
      compiler: gcc
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build_carl.sh
      after_success:
        - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
        - docker commit carl mvolk/carl:travis;
        - docker push mvolk/carl:travis;

    ###
    # Stage: Build (1st run)
    ###

    # debian-9 - DefaultDebug
    - stage: Build (1st run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebug LINUX=debian-9 COMPILER=gcc
      install:
        - rm -rf build
        - travis/install_linux.sh
      script:
        - travis/build.sh Build1
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # debian-9 - DefaultRelease
    - stage: Build (1st run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultRelease LINUX=debian-9 COMPILER=gcc
      install:
        - rm -rf build
        - travis/install_linux.sh
      script:
        - travis/build.sh Build1
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # ubuntu-17.10 - DefaultDebugTravis
    - stage: Build (1st run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebugTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - rm -rf build
        - travis/install_linux.sh
      script:
        - travis/build.sh Build1
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # ubuntu-17.10 - DefaultReleaseTravis
    - stage: Build (1st run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - rm -rf build
        - travis/install_linux.sh
      script:
        - travis/build.sh Build1
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;

    ###
    # Stage: Build (2nd run)
    ###

    # debian-9 - DefaultDebug
    - stage: Build (2nd run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebug LINUX=debian-9 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh Build2
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # debian-9 - DefaultRelease
    - stage: Build (2nd run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultRelease LINUX=debian-9 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh Build2
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # ubuntu-17.10 - DefaultDebugTravis
    - stage: Build (2nd run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebugTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh Build2
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # ubuntu-17.10 - DefaultReleaseTravis
    - stage: Build (2nd run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh Build2
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;

    ###
    # Stage: Build (3rd run)
    ###

    # debian-9 - DefaultDebug
    - stage: Build (3rd run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebug LINUX=debian-9 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh Build3
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # debian-9 - DefaultRelease
    - stage: Build (3rd run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultRelease LINUX=debian-9 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh Build3
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # ubuntu-17.10 - DefaultDebugTravis
    - stage: Build (3rd run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebugTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh Build3
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # ubuntu-17.10 - DefaultReleaseTravis
    - stage: Build (3rd run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh Build3
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;

    ###
    # Stage: Build (4th run)
    ###

    # debian-9 - DefaultDebug
    - stage: Build (4th run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebug LINUX=debian-9 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh BuildLast
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # debian-9 - DefaultRelease
    - stage: Build (4th run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultRelease LINUX=debian-9 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh BuildLast
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # ubuntu-17.10 - DefaultDebugTravis
    - stage: Build (4th run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebugTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh BuildLast
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # ubuntu-17.10 - DefaultReleaseTravis
    - stage: Build (4th run)
      os: linux
      compiler: gcc
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh BuildLast
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;

    ###
    # Stage: Test all
    ###

    # debian-9 - DefaultDebug
    - stage: Test all
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebug LINUX=debian-9 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh TestAll
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # debian-9 - DefaultRelease
    - stage: Test all
      os: linux
      compiler: gcc
      env: CONFIG=DefaultRelease LINUX=debian-9 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh TestAll
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
    # ubuntu-17.10 - DefaultDebugTravis
    - stage: Test all
      os: linux
      compiler: gcc
      env: CONFIG=DefaultDebugTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh TestAll
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
      after_success:
        - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
        - docker commit storm mvolk/storm:travis-debug;
        - docker push mvolk/storm:travis-debug;
    # ubuntu-17.10 - DefaultReleaseTravis
    - stage: Test all
      os: linux
      compiler: gcc
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
      install:
        - travis/install_linux.sh
      script:
        - travis/build.sh TestAll
      before_cache:
        - docker cp storm:/opt/storm/. .
      after_failure:
        - find build -iname '*err*.log' -type f -print -exec cat {} \;
      after_success:
        - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
        - docker commit storm mvolk/storm:travis;
        - docker push mvolk/storm:travis;
  allow_failures:
    - stage: Build (1st run)
      os: linux
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
    - stage: Build (2nd run)
      os: linux
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
    - stage: Build (3rd run)
      os: linux
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
    - stage: Build (4th run)
      os: linux
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc
    - stage: Test all
      os: linux
      env: CONFIG=DefaultReleaseTravis LINUX=ubuntu-17.10 COMPILER=gcc