From 49dda8c2cd98719b88ef8c67e14bce0f08bb1bd1 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Thu, 20 Sep 2018 14:25:22 +0200 Subject: [PATCH 1/2] CI: add flake8 check in travis --- .travis.yml | 1 + ci_scripts/test.sh | 43 ++++++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5bbc2928e3..550a050d1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ env: - DISTRIB="conda" PYTHON_VERSION="3.6" EXAMPLES="true" SKLEARN_VERSION="0.18.2" - DISTRIB="conda" PYTHON_VERSION="3.6" DOCTEST="true" SKLEARN_VERSION="0.18.2" # - DISTRIB="conda" PYTHON_VERSION="3.7" SKLEARN_VERSION="0.18.2" + - DISTRIB="conda" PYTHON_VERSION="3.6" DOCTEST="true" SKLEARN_VERSION="0.18.2" RUN_FLAKES="true" SKIP_TESTS="true" install: source ci_scripts/install.sh script: bash ci_scripts/test.sh diff --git a/ci_scripts/test.sh b/ci_scripts/test.sh index ba18d7b631..250b4c0619 100644 --- a/ci_scripts/test.sh +++ b/ci_scripts/test.sh @@ -1,25 +1,34 @@ set -e -# Get into a temp directory to run test from the installed scikit learn and -# check if we do not leave artifacts -mkdir -p $TEST_DIR +run_tests() { + # Get into a temp directory to run test from the installed scikit learn and + # check if we do not leave artifacts + mkdir -p $TEST_DIR -cwd=`pwd` -test_dir=$cwd/tests -doctest_dir=$cwd/doc + cwd=`pwd` + test_dir=$cwd/tests + doctest_dir=$cwd/doc -cd $TEST_DIR + cd $TEST_DIR + if [[ "$EXAMPLES" == "true" ]]; then + pytest -sv $test_dir/test_examples/ + elif [[ "$DOCTEST" == "true" ]]; then + python -m doctest $doctest_dir/usage.rst + fi -if [[ "$EXAMPLES" == "true" ]]; then - pytest -sv $test_dir/test_examples/ -elif [[ "$DOCTEST" == "true" ]]; then - python -m doctest $doctest_dir/usage.rst -fi + if [[ "$COVERAGE" == "true" ]]; then + PYTEST_ARGS='--cov=openml' + else + PYTEST_ARGS='' + fi + + pytest -n 4 --timeout=600 --timeout-method=thread -sv --ignore='test_OpenMLDemo.py' $PYTEST_ARGS $test_dir +} -if [[ "$COVERAGE" == "true" ]]; then - PYTEST_ARGS='--cov=openml' -else - PYTEST_ARGS='' +if [[ "$RUN_FLAKE8" == "true" ]]; then + source ci_scripts/flake8_diff.sh fi -pytest -n 4 --timeout=600 --timeout-method=thread -sv --ignore='test_OpenMLDemo.py' $PYTEST_ARGS $test_dir +if [[ "$SKIP_TESTS" != "true" ]]; then + run_tests +fi From 99b77d05c1ad44788eff027e98ddedc68335b1e2 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Thu, 20 Sep 2018 14:34:50 +0200 Subject: [PATCH 2/2] FIX: typo --- .travis.yml | 2 +- ci_scripts/install.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 550a050d1e..f08c8a3967 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ env: - DISTRIB="conda" PYTHON_VERSION="3.6" EXAMPLES="true" SKLEARN_VERSION="0.18.2" - DISTRIB="conda" PYTHON_VERSION="3.6" DOCTEST="true" SKLEARN_VERSION="0.18.2" # - DISTRIB="conda" PYTHON_VERSION="3.7" SKLEARN_VERSION="0.18.2" - - DISTRIB="conda" PYTHON_VERSION="3.6" DOCTEST="true" SKLEARN_VERSION="0.18.2" RUN_FLAKES="true" SKIP_TESTS="true" + - DISTRIB="conda" PYTHON_VERSION="3.6" SKLEARN_VERSION="0.18.2" RUN_FLAKE8="true" SKIP_TESTS="true" install: source ci_scripts/install.sh script: bash ci_scripts/test.sh diff --git a/ci_scripts/install.sh b/ci_scripts/install.sh index 098650115b..4e23056baf 100644 --- a/ci_scripts/install.sh +++ b/ci_scripts/install.sh @@ -39,6 +39,9 @@ fi if [[ "$COVERAGE" == "true" ]]; then pip install codecov pytest-cov fi +if [[ "$RUN_FLAKE8" == "true" ]]; then + pip install flake8 +fi python --version python -c "import numpy; print('numpy %s' % numpy.__version__)"