Run only relevant tests in Travis based on git diff. (#4271)

This commit is contained in:
justinwyang 2019-03-15 22:23:54 -07:00 committed by Robert Nishihara
parent a6a5b344b9
commit db9fe6619d
2 changed files with 134 additions and 10 deletions

View file

@ -28,11 +28,16 @@ matrix:
- RAY_USE_CMAKE=1
- RAY_INSTALL_JAVA=1
install:
- eval `python $TRAVIS_BUILD_DIR/ci/travis/determine_tests_to_run.py`
- if [ $RAY_CI_JAVA_AFFECTED != "1" ]; then exit; fi
- ./ci/travis/install-dependencies.sh
- export PATH="$HOME/miniconda/bin:$PATH"
- ./ci/travis/install-ray.sh
script:
- ./java/test.sh
- if [ $RAY_CI_JAVA_AFFECTED != "1" ]; then exit; fi
- ./java/test.sh
- os: linux
dist: trusty
@ -76,15 +81,22 @@ matrix:
dist: trusty
env: VALGRIND=1 PYTHON=2.7 PYTHONWARNINGS=ignore
before_install:
- eval `python $TRAVIS_BUILD_DIR/ci/travis/determine_tests_to_run.py`
- if [ $RAY_CI_PYTHON_AFFECTED != "1" ]; then exit; fi
- sudo apt-get update -qq
- sudo apt-get install -qq valgrind
install:
- if [ $RAY_CI_PYTHON_AFFECTED != "1" ]; then exit; fi
- ./ci/suppress_output ./ci/travis/install-bazel.sh
- ./ci/suppress_output ./ci/travis/install-dependencies.sh
- export PATH="$HOME/miniconda/bin:$PATH"
- ./ci/suppress_output ./ci/travis/install-ray.sh
script:
- if [ $RAY_CI_PYTHON_AFFECTED != "1" ]; then exit; fi
- bash src/ray/test/run_object_manager_valgrind.sh
- export RAY_PLASMA_STORE_VALGRIND=1
@ -105,10 +117,15 @@ matrix:
dist: trusty
env: LINUX_WHEELS=1 PYTHONWARNINGS=ignore
install:
- eval `python $TRAVIS_BUILD_DIR/ci/travis/determine_tests_to_run.py`
- if [ $RAY_CI_LINUX_WHEELS_AFFECTED != "1" ]; then exit; fi
- ./ci/suppress_output ./ci/travis/install-dependencies.sh
# This command should be kept in sync with ray/python/README-building-wheels.md.
- ./ci/suppress_output docker run --rm -w /ray -v `pwd`:/ray -ti rayproject/arrow_linux_x86_64_base:latest /ray/python/build-wheel-manylinux1.sh
script:
- if [ $RAY_CI_LINUX_WHEELS_AFFECTED != "1" ]; then exit; fi
- ./ci/travis/test-wheels.sh
# Build MacOS wheels.
@ -116,10 +133,15 @@ matrix:
osx_image: xcode7
env: MAC_WHEELS=1 PYTHONWARNINGS=ignore
install:
- eval `python $TRAVIS_BUILD_DIR/ci/travis/determine_tests_to_run.py`
- if [ $RAY_CI_MACOS_WHEELS_AFFECTED != "1" ]; then exit; fi
- ./ci/suppress_output ./ci/travis/install-dependencies.sh
# This command should be kept in sync with ray/python/README-building-wheels.md.
- ./python/build-wheel-macos.sh
script:
- if [ $RAY_CI_MACOS_WHEELS_AFFECTED != "1" ]; then exit; fi
- ./ci/travis/test-wheels.sh
# Test GCS integration
@ -133,6 +155,9 @@ matrix:
install:
- eval `python $TRAVIS_BUILD_DIR/ci/travis/determine_tests_to_run.py`
- if [ $RAY_CI_TUNE_AFFECTED != "1" ] && [ $RAY_CI_RLLIB_AFFECTED != "1" ] && [ $RAY_CI_PYTHON_AFFECTED != "1" ]; then exit; fi
- ./ci/suppress_output ./ci/travis/install-bazel.sh
- ./ci/suppress_output ./ci/travis/install-dependencies.sh
- export PATH="$HOME/miniconda/bin:$PATH"
@ -144,7 +169,6 @@ install:
- ./ci/suppress_output bash src/ray/test/run_object_manager_tests.sh
- ./ci/suppress_output bazel test --build_tests_only --test_lang_filters=cc ... -c opt
script:
- export PATH="$HOME/miniconda/bin:$PATH"
# The following is needed so cloudpickle can find some of the
@ -154,20 +178,21 @@ script:
# - export PYTHONPATH="$PYTHONPATH:./ci/"
# ray tune tests
- ./ci/suppress_output python python/ray/tune/tests/test_dependency.py
- if [ $RAY_CI_TUNE_AFFECTED == "1" ]; then ./ci/suppress_output python python/ray/tune/tests/test_dependency.py; fi
# `cluster_tests.py` runs on Jenkins, not Travis.
- python -m pytest --durations=10 --ignore=python/ray/tune/tests/test_cluster.py --ignore=python/ray/tune/tests/test_actor_reuse.py python/ray/tune/tests
- if [ $RAY_CI_TUNE_AFFECTED == "1" ]; then python -m pytest --durations=10 --ignore=python/ray/tune/tests/test_cluster.py --ignore=python/ray/tune/tests/test_actor_reuse.py python/ray/tune/tests; fi
# ray rllib tests
- python/ray/rllib/tests/run_silent.sh tests/test_catalog.py
- python/ray/rllib/tests/run_silent.sh tests/test_filters.py
- python/ray/rllib/tests/run_silent.sh tests/test_optimizers.py
- python/ray/rllib/tests/run_silent.sh tests/test_evaluators.py
- if [ $RAY_CI_RLLIB_AFFECTED == "1" ]; then python/ray/rllib/tests/run_silent.sh tests/test_catalog.py; fi
- if [ $RAY_CI_RLLIB_AFFECTED == "1" ]; then python/ray/rllib/tests/run_silent.sh tests/test_filters.py; fi
- if [ $RAY_CI_RLLIB_AFFECTED == "1" ]; then python/ray/rllib/tests/run_silent.sh tests/test_optimizers.py; fi
- if [ $RAY_CI_RLLIB_AFFECTED == "1" ]; then python/ray/rllib/tests/run_silent.sh tests/test_evaluators.py; fi
# ray tests
# Python3.5+ only. Otherwise we will get `SyntaxError` regardless of how we set the tester.
- python -c 'import sys;exit(sys.version_info>=(3,5))' || python -m pytest --durations=5 python/ray/experimental/test/async_test.py
- python -m pytest --durations=10 python/ray/tests
- if [ $RAY_CI_PYTHON_AFFECTED == "1" ]; then python -c 'import sys;exit(sys.version_info>=(3,5))' || python -m pytest --durations=5 python/ray/experimental/test/async_test.py; fi
- if [ $RAY_CI_PYTHON_AFFECTED == "1" ]; then python -m pytest --durations=10 python/ray/tests; fi
deploy:
- provider: s3
access_key_id: AKIAJ2L7XDUSZVTXI5QA

View file

@ -0,0 +1,99 @@
# Script used for checking changes for incremental testing cases
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import subprocess
def list_changed_files(commit_range):
"""Returns a list of names of files changed in the given commit range.
The function works by opening a subprocess and running git. If an error
occurs while running git, the script will abort.
Args:
commit_range (string): The commit range to diff, consisting of the two
commit IDs separated by \"..\"
Returns:
list: List of changed files within the commit range
"""
command = ["git", "diff", "--name-only", commit_range]
out = subprocess.check_output(command)
return [s.strip() for s in out.decode().splitlines() if s is not None]
if __name__ == "__main__":
RAY_CI_TUNE_AFFECTED = 0
RAY_CI_RLLIB_AFFECTED = 0
RAY_CI_JAVA_AFFECTED = 0
RAY_CI_PYTHON_AFFECTED = 0
RAY_CI_LINUX_WHEELS_AFFECTED = 0
RAY_CI_MACOS_WHEELS_AFFECTED = 0
if os.environ["TRAVIS_EVENT_TYPE"] == "pull_request":
files = list_changed_files(os.environ["TRAVIS_COMMIT_RANGE"].replace(
"...", ".."))
skip_prefix_list = [
"doc/", "examples/", "dev/", "docker/", "kubernetes/", "site/"
]
for changed_file in files:
if changed_file.startswith("python/ray/tune/"):
RAY_CI_TUNE_AFFECTED = 1
RAY_CI_RLLIB_AFFECTED = 1
RAY_CI_LINUX_WHEELS_AFFECTED = 1
RAY_CI_MACOS_WHEELS_AFFECTED = 1
elif changed_file.startswith("python/ray/rllib/"):
RAY_CI_RLLIB_AFFECTED = 1
RAY_CI_LINUX_WHEELS_AFFECTED = 1
RAY_CI_MACOS_WHEELS_AFFECTED = 1
elif changed_file.startswith("python/"):
RAY_CI_TUNE_AFFECTED = 1
RAY_CI_RLLIB_AFFECTED = 1
RAY_CI_PYTHON_AFFECTED = 1
RAY_CI_LINUX_WHEELS_AFFECTED = 1
RAY_CI_MACOS_WHEELS_AFFECTED = 1
elif changed_file.startswith("java/"):
RAY_CI_JAVA_AFFECTED = 1
elif any(
changed_file.startswith(prefix)
for prefix in skip_prefix_list):
# nothing is run but linting in these cases
pass
elif changed_file.startswith("src/"):
RAY_CI_TUNE_AFFECTED = 1
RAY_CI_RLLIB_AFFECTED = 1
RAY_CI_JAVA_AFFECTED = 1
RAY_CI_PYTHON_AFFECTED = 1
RAY_CI_LINUX_WHEELS_AFFECTED = 1
RAY_CI_MACOS_WHEELS_AFFECTED = 1
else:
RAY_CI_TUNE_AFFECTED = 1
RAY_CI_RLLIB_AFFECTED = 1
RAY_CI_JAVA_AFFECTED = 1
RAY_CI_PYTHON_AFFECTED = 1
RAY_CI_LINUX_WHEELS_AFFECTED = 1
RAY_CI_MACOS_WHEELS_AFFECTED = 1
else:
RAY_CI_TUNE_AFFECTED = 1
RAY_CI_RLLIB_AFFECTED = 1
RAY_CI_JAVA_AFFECTED = 1
RAY_CI_PYTHON_AFFECTED = 1
RAY_CI_LINUX_WHEELS_AFFECTED = 1
RAY_CI_MACOS_WHEELS_AFFECTED = 1
print("export RAY_CI_TUNE_AFFECTED={}".format(RAY_CI_TUNE_AFFECTED))
print("export RAY_CI_RLLIB_AFFECTED={}".format(RAY_CI_RLLIB_AFFECTED))
print("export RAY_CI_JAVA_AFFECTED={}".format(RAY_CI_JAVA_AFFECTED))
print("export RAY_CI_PYTHON_AFFECTED={}".format(RAY_CI_PYTHON_AFFECTED))
print("export RAY_CI_LINUX_WHEELS_AFFECTED={}"
.format(RAY_CI_LINUX_WHEELS_AFFECTED))
print("export RAY_CI_MACOS_WHEELS_AFFECTED={}"
.format(RAY_CI_MACOS_WHEELS_AFFECTED))