From 9cc4cc6a52f4ee192da0224b3b5928135f95dc8f Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Thu, 4 Jul 2019 23:22:01 -0700 Subject: [PATCH] Fail format.sh if yapf/flake8 versions are incorrect. (#5083) --- .travis.yml | 1 - ci/travis/format.sh | 23 +++++++++++++++++++++++ ci/travis/install-dependencies.sh | 2 +- python/ray/tune/requirements-dev.txt | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec02918ff..21bba5e6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,6 @@ matrix: env: LINT=1 PYTHONWARNINGS=ignore before_install: - sudo apt-get update -qq - - sudo apt-get install -qq clang-format-6.0 install: [] script: - ./ci/travis/check-git-clang-format-output.sh diff --git a/ci/travis/format.sh b/ci/travis/format.sh index 9089404f6..6b78bcd20 100755 --- a/ci/travis/format.sh +++ b/ci/travis/format.sh @@ -22,6 +22,29 @@ if ! [[ -e "$ROOT/.git/refs/remotes/upstream" ]]; then git remote add 'upstream' 'https://github.com/ray-project/ray.git' fi +FLAKE8_VERSION=$(flake8 --version | awk '{print $1}') +YAPF_VERSION=$(yapf --version | awk '{print $2}') + +if [[ $FLAKE8_VERSION != "3.7.7" ]]; then + echo "Please install flake8==3.7.7. You currently are using $FLAKE8_VERSION." + exit 1 +fi + +if [[ $YAPF_VERSION != "0.23.0" ]]; then + echo "Please install yapf==0.23.0. You currently are using $YAPF_VERSION." + exit 1 +fi + +if which clang-format >/dev/null; then + CLANG_FORMAT_VERSION=$(clang-format --version | awk '{print $3}') + if [[ $CLANG_FORMAT_VERSION != "7.0.0" ]]; then + echo "Please install clang-format 7.0.0. You currently are using $CLANG_FORMAT_VERSION." + exit 1 + fi +else + echo "WARNING: clang-format is not installed!" +fi + # Only fetch master since that's the branch we're diffing against. git fetch upstream master || true diff --git a/ci/travis/install-dependencies.sh b/ci/travis/install-dependencies.sh index 20ff2e64d..8864c2fae 100755 --- a/ci/travis/install-dependencies.sh +++ b/ci/travis/install-dependencies.sh @@ -57,7 +57,7 @@ elif [[ "$LINT" == "1" ]]; then bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" # Install Python linting tools. - pip install -q flake8 flake8-comprehensions + pip install -q flake8==3.7.7 flake8-comprehensions pip install flake8-quotes==2.0.0 elif [[ "$LINUX_WHEELS" == "1" ]]; then sudo apt-get install docker diff --git a/python/ray/tune/requirements-dev.txt b/python/ray/tune/requirements-dev.txt index 9d3d3ddab..337ed15fd 100644 --- a/python/ray/tune/requirements-dev.txt +++ b/python/ray/tune/requirements-dev.txt @@ -1,4 +1,4 @@ -flake8 +flake8==3.7.7 flake8-quotes gym opencv-python