test.sh 5.09 KB
Newer Older
1
2
3
if [[ ${TASK} == "gpu" ]] && [[ $TRAVIS_OS_NAME == "linux" ]]; then
    wget "https://github.com/Microsoft/LightGBM/releases/download/v2.0.12/AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2";
    tar -xjf AMD-APP-SDK*.tar.bz2;
wxchan's avatar
wxchan committed
4
5
6
7
8
    AMDAPPSDK=${HOME}/AMDAPPSDK;
    export OPENCL_VENDOR_PATH=${AMDAPPSDK}/etc/OpenCL/vendors;
    mkdir -p ${OPENCL_VENDOR_PATH};
    sh AMD-APP-SDK*.sh --tar -xf -C ${AMDAPPSDK};
    echo libamdocl64.so > ${OPENCL_VENDOR_PATH}/amdocl64.icd;
9
    export LD_LIBRARY_PATH="$AMDAPPSDK/lib/x86_64:$LD_LIBRARY_PATH";
wxchan's avatar
wxchan committed
10
11
fi

12
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
13
14
    export CXX=g++-8
    export CC=gcc-8
15
16
fi

17
18
LGB_VER=$(head -n 1 VERSION.txt)

19
20
conda create -q -n test-env python=$PYTHON_VERSION
source activate test-env
21

wxchan's avatar
wxchan committed
22
23
cd $TRAVIS_BUILD_DIR

24
if [[ ${TASK} == "check-docs" ]]; then
25
26
27
28
29
30
    if [[ $TRAVIS_OS_NAME != "osx" ]]; then
        sudo apt-get install linkchecker
    fi
    if [[ ${PYTHON_VERSION} == "2.7" ]]; then
        conda install mock
    fi
31
    conda install sphinx "sphinx_rtd_theme>=0.3"  # html5validator
32
    pip install rstcheck
33
34
35
    cd python-package
    rstcheck --report warning `find . -type f -name "*.rst"` || exit -1
    cd ../docs
36
    rstcheck --report warning --ignore-directives=autoclass,autofunction `find . -type f -name "*.rst"` || exit -1
37
    make html || exit -1
38
    find ./_build/html/ -type f -name '*.html' -exec \
39
40
    sed -i -e 's;\(\.\/[^.]*\.\)rst\([^[:space:]]*\);\1html\2;g' {} \;  # Emulate js function
#    html5validator --root ./_build/html/ || exit -1
41
42
43
    if [[ $TRAVIS_OS_NAME != "osx" ]]; then
        linkchecker --config=.linkcheckerrc ./_build/html/*.html || exit -1
    fi
44
45
46
    exit 0
fi

wxchan's avatar
wxchan committed
47
if [[ ${TASK} == "pylint" ]]; then
48
49
    conda install pycodestyle
    pycodestyle --ignore=E501,W503 --exclude=./compute,./docs,./.nuget . || exit -1
wxchan's avatar
wxchan committed
50
51
52
53
    exit 0
fi

if [[ ${TASK} == "if-else" ]]; then
54
    conda install numpy
wxchan's avatar
wxchan committed
55
    mkdir build && cd build && cmake .. && make lightgbm || exit -1
wxchan's avatar
wxchan committed
56
    cd $TRAVIS_BUILD_DIR/tests/cpp_test && ../../lightgbm config=train.conf convert_model_language=cpp convert_model=../../src/boosting/gbdt_prediction.cpp && ../../lightgbm config=predict.conf output_result=origin.pred || exit -1
wxchan's avatar
wxchan committed
57
58
59
60
61
    cd $TRAVIS_BUILD_DIR/build && make lightgbm || exit -1
    cd $TRAVIS_BUILD_DIR/tests/cpp_test && ../../lightgbm config=predict.conf output_result=ifelse.pred && python test.py || exit -1
    exit 0
fi

62
conda install numpy nose scipy scikit-learn pandas matplotlib pytest
wxchan's avatar
wxchan committed
63

64
if [[ ${TASK} == "sdist" ]]; then
wxchan's avatar
wxchan committed
65
66
67
    cd $TRAVIS_BUILD_DIR/python-package && python setup.py sdist || exit -1
    cd $TRAVIS_BUILD_DIR/python-package/dist && pip install lightgbm-$LGB_VER.tar.gz -v || exit -1
    cd $TRAVIS_BUILD_DIR && pytest tests/python_package_test || exit -1
68
69
    exit 0
elif [[ ${TASK} == "bdist" ]]; then
Guolin Ke's avatar
Guolin Ke committed
70
71
    if [[ $TRAVIS_OS_NAME == "osx" ]]; then
        cd $TRAVIS_BUILD_DIR/python-package && python setup.py bdist_wheel --plat-name=macosx --universal || exit -1
72
        mv dist/lightgbm-${LGB_VER}-py2.py3-none-macosx.whl dist/lightgbm-${LGB_VER}-py2.py3-none-macosx_10_9_x86_64.macosx_10_10_x86_64.macosx_10_11_x86_64.macosx_10_12_x86_64.macosx_10_13_x86_64.whl
Guolin Ke's avatar
Guolin Ke committed
73
74
75
    else
        cd $TRAVIS_BUILD_DIR/python-package && python setup.py bdist_wheel --plat-name=manylinux1_x86_64 --universal || exit -1
    fi
76
77
    cd $TRAVIS_BUILD_DIR/python-package && pip install dist/*.whl || exit -1
    cd $TRAVIS_BUILD_DIR && pytest tests/python_package_test || exit -1
wxchan's avatar
wxchan committed
78
79
80
81
82
    exit 0
fi

if [[ ${TASK} == "gpu" ]]; then 
    conda install --yes -c conda-forge boost=1.63.0
83
    if [[ ${METHOD} == "pip" ]]; then
84
        sed -i 's/std::string device_type = "cpu";/std::string device_type = "gpu";/' ../include/LightGBM/config.h
Guolin Ke's avatar
Guolin Ke committed
85
        cd $TRAVIS_BUILD_DIR/python-package && python setup.py sdist || exit -1
86
        cd $TRAVIS_BUILD_DIR/python-package/dist && pip install lightgbm-$LGB_VER.tar.gz -v --install-option=--gpu --install-option="--boost-root=$HOME/miniconda/envs/test-env/" --install-option="--opencl-include-dir=$AMDAPPSDK/include/" || exit -1
87
88
89
        cd $TRAVIS_BUILD_DIR && pytest tests/python_package_test || exit -1
        exit 0
    fi
wxchan's avatar
wxchan committed
90
91
92
93
94
fi

mkdir build && cd build

if [[ ${TASK} == "mpi" ]]; then
95
96
97
    cd $TRAVIS_BUILD_DIR/python-package && python setup.py sdist || exit -1
    cd $TRAVIS_BUILD_DIR/python-package/dist && pip install lightgbm-$LGB_VER.tar.gz -v --install-option=--mpi || exit -1
    cd $TRAVIS_BUILD_DIR/build
wxchan's avatar
wxchan committed
98
99
    cmake -DUSE_MPI=ON ..
elif [[ ${TASK} == "gpu" ]]; then
100
    cmake -DUSE_GPU=ON -DBOOST_ROOT="$HOME/miniconda/envs/test-env/" -DOpenCL_INCLUDE_DIR=$AMDAPPSDK/include/ ..
101
    sed -i 's/std::string device_type = "cpu";/std::string device_type = "gpu";/' ../include/LightGBM/config.h
wxchan's avatar
wxchan committed
102
103
104
105
106
107
108
109
else
    cmake ..
fi

make _lightgbm || exit -1

cd $TRAVIS_BUILD_DIR/python-package && python setup.py install --precompile || exit -1
cd $TRAVIS_BUILD_DIR && pytest . || exit -1
110
111

if [[ ${TASK} == "regular" ]]; then
112
113
114
115
116
117
118
    conda install python-graphviz
    cd $TRAVIS_BUILD_DIR/examples/python-guide
    sed -i'.bak' '/import lightgbm as lgb/a\
import matplotlib\
matplotlib.use\(\"Agg\"\)\
' plot_example.py  # prevent interactive window mode
    for f in *.py; do python $f || exit -1; done  # run all examples
119
fi