# disable sudo for container build.
sudo: required

# Enabling test OS X
os:
  - linux
  - osx

osx_image: xcode10.3
dist: bionic

# Use Build Matrix to do lint and build seperately
env:
  matrix:
    # python package test
    - TASK=python_test
    # test installation of Python source distribution
    - TASK=python_sdist_test
    # java package test
    - TASK=java_test
    # cmake test
    - TASK=cmake_test

matrix:
  exclude:
    - os: linux
      env: TASK=python_test
    - os: linux
      env: TASK=java_test
    - os: linux
      env: TASK=cmake_test

# dependent brew packages
addons:
  homebrew:
    packages:
      - cmake
      - libomp
      - graphviz
      - openssl
      - libgit2
      - wget
      - r
    update: true

before_install:
  - source dmlc-core/scripts/travis/travis_setup_env.sh
  - if [ "${TASK}" != "python_sdist_test" ]; then export PYTHONPATH=${PYTHONPATH}:${PWD}/python-package; fi
  - echo "MAVEN_OPTS='-Xmx2g -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=512m -Dorg.slf4j.simpleLogger.defaultLogLevel=error'" > ~/.mavenrc

install:
  - source tests/travis/setup.sh

script:
  - tests/travis/run_test.sh

cache:
  directories:
    - ${HOME}/.cache/usr
    - ${HOME}/.cache/pip

before_cache:
  - dmlc-core/scripts/travis/travis_before_cache.sh

after_failure:
  - tests/travis/travis_after_failure.sh

after_success:
  - tree build
  - bash <(curl -s https://codecov.io/bash) -a '-o src/ src/*.c'

notifications:
  email:
    on_success: change
    on_failure: always
