sudo: required

language: generic

matrix:
  include:
    - os: linux
      dist: trusty
      env: PYTHON=2.7

    - os: linux
      dist: trusty
      env: PYTHON=3.5

    - os: osx
      osx_image: xcode7
      env: PYTHON=2.7

    - os: osx
      osx_image: xcode7
      env: PYTHON=3.5

    - os: linux
      dist: trusty
      env:
        - JDK='Oracle JDK 8'
        - PYTHON=3.5
      install:
        - ./.travis/install-dependencies.sh
        - export PATH="$HOME/miniconda/bin:$PATH"
      script:
      - ./java/test.sh

    - os: linux
      dist: trusty
      env: LINT=1
      before_install:
        # In case we ever want to use a different version of clang-format:
        #- wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
        #- echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty main" | sudo tee -a /etc/apt/sources.list > /dev/null
        - sudo apt-get update -qq
        - sudo apt-get install -qq clang-format-3.8
      install: []
      script:
        - .travis/check-git-clang-format-output.sh
        # Try generating Sphinx documentation. To do this, we need to install
        # Ray first.
        - ./.travis/install-dependencies.sh
        - export PATH="$HOME/miniconda/bin:$PATH"
        - cd doc
        - pip install -q -r requirements-doc.txt
        - pip install yapf
        - sphinx-build -W -b html -d _build/doctrees source _build/html
        - cd ..
        # Run Python linting, ignore dict vs {} (C408), others are defaults
        - flake8 --exclude=python/ray/core/src/common/flatbuffers_ep-prefix/,python/ray/core/generated/,src/common/format/,doc/source/conf.py,python/ray/cloudpickle/ --ignore=C408,E121,E123,E126,E226,E24,E704,W503,W504
        - .travis/yapf.sh --all

    - os: linux
      dist: trusty
      env: VALGRIND=1 PYTHON=2.7
      before_install:
        - sudo apt-get update -qq
        - sudo apt-get install -qq valgrind
      install:
        - ./.travis/install-dependencies.sh
        - export PATH="$HOME/miniconda/bin:$PATH"
        - ./.travis/install-ray.sh

      script:
        - cd build
        - bash ../src/common/test/run_valgrind.sh
        - bash ../src/plasma/test/run_valgrind.sh
        - bash ../src/local_scheduler/test/run_valgrind.sh
        - bash ../src/ray/test/run_object_manager_valgrind.sh
        - cd ..

        - python ./python/ray/plasma/test/test.py valgrind
        - python ./python/ray/local_scheduler/test/test.py valgrind
        - python ./python/ray/global_scheduler/test/test.py valgrind

    # Build Linux wheels.
    - os: linux
      dist: trusty
      env: LINUX_WHEELS=1
      install:
        - ./.travis/install-dependencies.sh
        # This command should be kept in sync with ray/python/README-building-wheels.md.
        - docker run --rm -w /ray -v `pwd`:/ray -ti quay.io/xhochy/arrow_manylinux1_x86_64_base:latest /ray/python/build-wheel-manylinux1.sh
      script:
        - ./.travis/test-wheels.sh

    # Build MacOS wheels.
    - os: osx
      osx_image: xcode7
      env: MAC_WHEELS=1
      install:
        - ./.travis/install-dependencies.sh
        # This command should be kept in sync with ray/python/README-building-wheels.md.
        - ./python/build-wheel-macos.sh
      script:
        - ./.travis/test-wheels.sh

    # Test GCS integration
    - os: linux
      dist: trusty
      env:
        - PYTHON=3.5
        - RAY_USE_NEW_GCS=on
        - RAY_USE_XRAY=1

    - os: linux
      dist: trusty
      env: PYTHON=3.5 RAY_USE_XRAY=1
      install:
        - ./.travis/install-dependencies.sh
        - export PATH="$HOME/miniconda/bin:$PATH"
        - ./.travis/install-ray.sh
        - ./.travis/install-cython-examples.sh
      script:
        - export PATH="$HOME/miniconda/bin:$PATH"
        # The following is needed so cloudpickle can find some of the
        # class definitions: The main module of tests that are run
        # with pytest have the same name as the test file -- and this
        # module is only found if the test directory is in the PYTHONPATH.
        - export PYTHONPATH="$PYTHONPATH:./test/"

        - python -m pytest python/ray/common/test/test.py
        - python -m pytest python/ray/common/redis_module/runtest.py
        - python -m pytest python/ray/plasma/test/test.py
        # - python -m pytest python/ray/local_scheduler/test/test.py
        # - python -m pytest python/ray/global_scheduler/test/test.py

        - python -m pytest python/ray/test/test_queue.py
        - python -m pytest test/xray_test.py

        # The --assert=plain here is because pytest's assertion
        # rewriting mechanism seems to mess up on this file,
        # see https://github.com/ray-project/ray/issues/2514
        - python -m pytest -v --assert=plain test/runtest.py
        - python -m pytest test/array_test.py
        - python -m pytest test/actor_test.py
        - python -m pytest test/autoscaler_test.py
        - python -m pytest test/tensorflow_test.py
        - python -m pytest test/failure_test.py
        - python -m pytest test/microbenchmarks.py
        - python -m pytest test/stress_tests.py
        - pytest test/component_failures_test.py
        - python test/multi_node_test.py
        - python -m pytest test/recursion_test.py
        - pytest test/monitor_test.py
        - python -m pytest test/cython_test.py
        - python -m pytest test/credis_test.py

        # ray tune tests
        - python python/ray/tune/test/dependency_test.py
        - python -m pytest python/ray/tune/test/trial_runner_test.py
        - python -m pytest python/ray/tune/test/trial_scheduler_test.py
        - python -m pytest python/ray/tune/test/experiment_test.py
        - python -m pytest python/ray/tune/test/tune_server_test.py
        - python -m pytest python/ray/tune/test/ray_trial_executor_test.py

        # ray rllib tests
        - python -m pytest python/ray/rllib/test/test_catalog.py
        - python -m pytest python/ray/rllib/test/test_filters.py
        - python -m pytest python/ray/rllib/test/test_optimizers.py
        - python -m pytest python/ray/rllib/test/test_evaluators.py


install:
  - ./.travis/install-dependencies.sh
  - export PATH="$HOME/miniconda/bin:$PATH"
  - ./.travis/install-ray.sh
  - ./.travis/install-cython-examples.sh

  - cd build
  - bash ../src/ray/test/run_gcs_tests.sh
  # Raylet tests.
  - bash ../src/ray/test/run_object_manager_tests.sh
  - ./src/ray/raylet/task_test
  - ./src/ray/raylet/worker_pool_test
  - ./src/ray/raylet/lineage_cache_test
  - ./src/ray/raylet/task_dependency_manager_test
  - ./src/ray/raylet/reconstruction_policy_test
  - ./src/ray/util/logging_test --gtest_filter=PrintLogTest*

  - bash ../src/common/test/run_tests.sh
  - bash ../src/plasma/test/run_tests.sh
  - bash ../src/local_scheduler/test/run_tests.sh
  - cd ..

script:
  - export PATH="$HOME/miniconda/bin:$PATH"
  # The following is needed so cloudpickle can find some of the
  # class definitions: The main module of tests that are run
  # with pytest have the same name as the test file -- and this
  # module is only found if the test directory is in the PYTHONPATH.
  - export PYTHONPATH="$PYTHONPATH:./test/"

  - python -m pytest python/ray/common/test/test.py
  - python -m pytest python/ray/common/redis_module/runtest.py
  - python -m pytest python/ray/plasma/test/test.py
  - python -m pytest python/ray/local_scheduler/test/test.py
  - python -m pytest python/ray/global_scheduler/test/test.py

  - python -m pytest python/ray/test/test_queue.py
  - python -m pytest test/xray_test.py

  # The --assert=plain here is because pytest's assertion
  # rewriting mechanism seems to mess up on this file,
  # see https://github.com/ray-project/ray/issues/2514
  - python -m pytest --assert=plain -v test/runtest.py
  - python -m pytest test/array_test.py
  - python -m pytest test/actor_test.py
  - python -m pytest test/autoscaler_test.py
  - python -m pytest test/tensorflow_test.py
  - python -m pytest test/failure_test.py
  - python -m pytest test/microbenchmarks.py
  - python -m pytest test/stress_tests.py
  - python -m pytest test/component_failures_test.py
  - python test/multi_node_test.py
  - python -m pytest test/recursion_test.py
  - python -m pytest test/monitor_test.py
  - python -m pytest test/cython_test.py
  - python -m pytest test/credis_test.py

  # ray tune tests
  - python python/ray/tune/test/dependency_test.py
  - python -m pytest python/ray/tune/test/trial_runner_test.py
  - python -m pytest python/ray/tune/test/trial_scheduler_test.py
  - python -m pytest python/ray/tune/test/experiment_test.py
  - python -m pytest python/ray/tune/test/tune_server_test.py
  - python -m pytest python/ray/tune/test/ray_trial_executor_test.py

  # ray rllib tests
  - python -m pytest python/ray/rllib/test/test_catalog.py
  - python -m pytest python/ray/rllib/test/test_filters.py
  - python -m pytest python/ray/rllib/test/test_optimizers.py
  - python -m pytest python/ray/rllib/test/test_evaluators.py

deploy:
  - provider: s3
    access_key_id: AKIAJ2L7XDUSZVTXI5QA
    secret_access_key:
      secure: OS9V8c/fQ9SIOP+Lg2MIz+PtCSKNQVB3mubscDRHKJcCmOp3cB6AKsC/yepbNZvvjDD/ncW2v6KJVsUEneAeDKrZQWSIpNb34yGAvWb7g4xleLxiadNtx6XEzjWaOcg+Y6409e68XeoHq/5ItopWNQ9p9NHXgsoHbZaOurPyHNskNgwBVaObCy+cCak7ifkITDk6cil0OJYnTbOe3NhcU82Fh5BZzS2+G2qNq8tGNcbfINhq0rruWIBuV5WRB/14CmBR+mou74qFSiiodH/MKbOcplx9+BxoOsTnkl7SeyybcK6DX6jxJCuhSBIjct9uT8Qdovv6mzOMkXvLkLKFkHfkTJSGBRIIZEvkPvzhlEriqTcr4tX/MV8HKs/Acz1NnlD0tNEygOr3VaiSLB0dvpz4iCeI9berqSu/jV1VI1X5iVNfChYbOMQ+OYafJMs5WdO60AMWIHy60U511FjAlbS7IubXBjfhoCItIB1xlVNI7FfKaRbNRwP5qvPenB8FUgZpv3UBg5OZDkeBXSNoLydr0w505p6s8Jqnz750TpVYI11fih5D0N3Ea57OwQr9r/rk+Z8aGeTpWj6hIgQiNkrIf2VZnWTApd+utJPw3X3txUEcnOtcdDnMsPuEIeMvIDrrFMRwzClqMNXq9MewU43wp7cCl67YmDBDKubl7Vs=
    bucket: ray-wheels
    acl: public_read
    region: us-west-2
    local_dir: .whl
    upload-dir: $TRAVIS_COMMIT
    skip_cleanup: true
    only:
      - master
    on:
      repo: ray-project/ray
      condition: $LINUX_WHEELS = 1 || $MAC_WHEELS = 1
  - provider: s3
    access_key_id: AKIAJ2L7XDUSZVTXI5QA
    secret_access_key:
      secure: OS9V8c/fQ9SIOP+Lg2MIz+PtCSKNQVB3mubscDRHKJcCmOp3cB6AKsC/yepbNZvvjDD/ncW2v6KJVsUEneAeDKrZQWSIpNb34yGAvWb7g4xleLxiadNtx6XEzjWaOcg+Y6409e68XeoHq/5ItopWNQ9p9NHXgsoHbZaOurPyHNskNgwBVaObCy+cCak7ifkITDk6cil0OJYnTbOe3NhcU82Fh5BZzS2+G2qNq8tGNcbfINhq0rruWIBuV5WRB/14CmBR+mou74qFSiiodH/MKbOcplx9+BxoOsTnkl7SeyybcK6DX6jxJCuhSBIjct9uT8Qdovv6mzOMkXvLkLKFkHfkTJSGBRIIZEvkPvzhlEriqTcr4tX/MV8HKs/Acz1NnlD0tNEygOr3VaiSLB0dvpz4iCeI9berqSu/jV1VI1X5iVNfChYbOMQ+OYafJMs5WdO60AMWIHy60U511FjAlbS7IubXBjfhoCItIB1xlVNI7FfKaRbNRwP5qvPenB8FUgZpv3UBg5OZDkeBXSNoLydr0w505p6s8Jqnz750TpVYI11fih5D0N3Ea57OwQr9r/rk+Z8aGeTpWj6hIgQiNkrIf2VZnWTApd+utJPw3X3txUEcnOtcdDnMsPuEIeMvIDrrFMRwzClqMNXq9MewU43wp7cCl67YmDBDKubl7Vs=
    bucket: ray-wheels
    acl: public_read
    region: us-west-2
    local_dir: .whl
    upload-dir: latest
    skip_cleanup: true
    only:
      - master
    on:
      repo: ray-project/ray
      condition: $LINUX_WHEELS = 1 || $MAC_WHEELS = 1
