language: java
jdk: oraclejdk8

# This (sudo: false) is needed to "run on container-based infrastructure" on
# which cache: is available
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: required

# http://docs.travis-ci.com/user/caching/#Arbitrary-directories
cache:
  directories:
  - $HOME/.m2
  - download

matrix:
      fast_finish: true

addons:
  apt_packages:
    - git
    - cmake
    - libgtest-dev

env:
    - BUILD="build-python"
    - BUILD="build-java"

before_install:
    # The installation of the python dependencies must be done in that level for now
    # otherwise they are not available in the containers,
    # see https://github.com/travis-ci/travis-ci/issues/8048
    # Changing the value for sudo will also need to be reviewed at the same time
    # This will need to be reviewed when the issue above is fixed
    - export PATH=/usr/bin/:$PATH
    - sudo apt-get install -y zeroc-ice35 python-imaging python-numpy python-tables python-yaml
    # upgrade numexpr to fix table test failures
    - sudo pip install -U numexpr
    - pip install --user pytest
    - if [[ $BUILD == 'build-python' ]]; then pip install --user -r ./components/tools/OmeroWeb/requirements-py27-all-ice35.txt; fi
    - export PATH=$PATH:$HOME/.local/bin
    - if [[ $BUILD == 'build-python' ]]; then travis_retry pip install --user flake8==2.4.0 pytest==2.7.3; fi
    - if [[ $BUILD == 'build-python' ]]; then ./components/tools/travis-build py-flake8; fi

# retries the build due to:
# https://github.com/travis-ci/travis-ci/issues/2507
install:
    - if [[ $BUILD == 'build-python' ]]; then travis_retry ./components/tools/travis-build py-build; fi
    - if [[ $BUILD == 'build-java' ]]; then travis_retry ./components/tools/travis-build java-build; fi

script:
    - if [[ $BUILD == 'build-python' ]]; then ./components/tools/travis-build py-test; fi
    - if [[ $BUILD == 'build-java' ]]; then ./components/tools/travis-build java-test; fi

notifications:
  slack:
    secure: YoCiRg7KuG+jQdW2wD5aBVurfJoKTT+/bKexZD/t5w+WjR4oKi0eoj+La4niUHxmUGHmJAuRYq/7wpP7nq1RBOcXQYpq9S842tmhhQZeC2EGFGw3YlBBEQj9oqMl9JlcI4lTkSo4V/uCnwdrFAGfGaAjICuCnEb9rvBhsXeqYtU=
    on_success: change
