From 7a7b30089b98bd33651e54e6dc9a8a918ddf900f Mon Sep 17 00:00:00 2001 From: tqchen Date: Tue, 10 Jan 2017 11:41:15 -0800 Subject: [PATCH 1/3] Setup Travis CI --- .travis.yml | 64 ++++++++++++++++++++++++++++ tests/travis/run_test.sh | 46 ++++++++++++++++++++ tests/travis/setup.sh | 15 +++++++ tests/travis/travis_after_failure.sh | 1 + 4 files changed, 126 insertions(+) create mode 100644 .travis.yml create mode 100755 tests/travis/run_test.sh create mode 100755 tests/travis/setup.sh create mode 100755 tests/travis/travis_after_failure.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000000..8aa4e91bd6e0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,64 @@ +sudo: false + +language: cpp + +os: + - linux + - osx + +env: + # code analysis + - TASK=lint + - TASK=cpp_test + - TASK=python_test + +branches: + only: + - master + +matrix: + exclude: + - os: osx + env: TASK=lint + +# dependent apt packages +addons: + apt: + packages: + - doxygen + - wget + - git + - unzip + - gcc-4.8 + - g++-4.8 + - python-numpy + - python-nose + - python3-dev + - python3-nose + - graphviz + +before_install: + - source dmlc-core/scripts/travis/travis_setup_env.sh + - export PYTHONPATH=${PYTHONPATH}:${PWD}/python + +install: + - source tests/travis/setup.sh + +script: + - tests/travis/run_test.sh + +cache: + directories: + - ${HOME}/.cache/usr + +before_cache: + - dmlc-core/scripts/travis/travis_before_cache.sh + +after_failure: + - tests/travis/travis_after_failure.sh + +notifications: +# Emails are sent to the committer's git-configured email address by default, + email: + on_success: change + on_failure: always diff --git a/tests/travis/run_test.sh b/tests/travis/run_test.sh new file mode 100755 index 000000000000..039a1abc0033 --- /dev/null +++ b/tests/travis/run_test.sh @@ -0,0 +1,46 @@ +#!/bin/bash + + +if [ ${TASK} == "lint" ]; then + make lint || exit -1 + echo "Check documentations of c++ code..." + make doc 2>log.txt + (cat log.txt| grep -v ENABLE_PREPROCESSING |grep -v "unsupported tag") > logclean.txt + echo "---------Error Log----------" + cat logclean.txt + echo "----------------------------" + (cat logclean.txt|grep warning) && exit -1 + (cat logclean.txt|grep error) && exit -1 + exit 0 +fi + + +if [ ! ${TRAVIS_OS_NAME} == "osx" ]; then + # use g++-4.8 for linux + if [ ${CXX} == "g++" ]; then + export CXX=g++-4.8 + fi +fi + +if [ ${TASK} == "cpp_test" ]; then + make -f dmlc-core/scripts/packages.mk gtest + make test || exit -1 + for test in tests/cpp/*_test; do + ./$test || exit -1 + done + exit 0 +fi + +# run two test one for cython, one for ctypes +if [ ${TASK} == "python_test" ]; then + make clean + make -j all || exit -1 + if [ ${TRAVIS_OS_NAME} == "osx" ]; then + python -m nose tests/python/ || exit -1 + python3 -m nose tests/python/ || exit -1 + else + nosetests tests/python/ || exit -1 + nosetests3 tests/python/ || exit -1 + fi + exit 0 +fi diff --git a/tests/travis/setup.sh b/tests/travis/setup.sh new file mode 100755 index 000000000000..2e6545a50d3f --- /dev/null +++ b/tests/travis/setup.sh @@ -0,0 +1,15 @@ +#!/bin/bash + + +if [ ${TRAVIS_OS_NAME} == "osx" ]; then + brew update + brew install python3 + if [ ${TASK} == "python_test" ]; then + python -m pip install --user nose + python3 -m pip install --user nose + fi +fi + +if [ ${TASK} == "lint" ]; then + pip install --user cpplint 'pylint==1.4.4' 'astroid==1.3.6' +fi diff --git a/tests/travis/travis_after_failure.sh b/tests/travis/travis_after_failure.sh new file mode 100755 index 000000000000..a9bf588e2f88 --- /dev/null +++ b/tests/travis/travis_after_failure.sh @@ -0,0 +1 @@ +#!/bin/bash From 8f50448579701bd5a52d928419df72848b93c147 Mon Sep 17 00:00:00 2001 From: tqchen Date: Tue, 10 Jan 2017 12:11:50 -0800 Subject: [PATCH 2/3] add source --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8aa4e91bd6e0..0a1e518469c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,8 @@ matrix: # dependent apt packages addons: + sources: + - ubuntu-toolchain-r-test apt: packages: - doxygen From 7eb51fe1b49854309bd6ae32dfd2937aa2c27f81 Mon Sep 17 00:00:00 2001 From: tqchen Date: Tue, 10 Jan 2017 12:14:06 -0800 Subject: [PATCH 3/3] fix source --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a1e518469c8..266ca62a6b78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,9 +23,9 @@ matrix: # dependent apt packages addons: - sources: - - ubuntu-toolchain-r-test apt: + sources: + - ubuntu-toolchain-r-test packages: - doxygen - wget