test.sh 5.12 KB
Newer Older
1
if [[ ${TASK} == "gpu" ]]; then
wxchan's avatar
wxchan committed
2
3
4
5
6
7
8
9
10
11
    bash .travis/amd_sdk.sh;
    tar -xjf AMD-SDK.tar.bz2;
    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;
    export LD_LIBRARY_PATH=${AMDAPPSDK}/lib/x86_64:${LD_LIBRARY_PATH};
    chmod +x ${AMDAPPSDK}/bin/x86_64/clinfo;
    ${AMDAPPSDK}/bin/x86_64/clinfo;
12
13
14
    export LIBRARY_PATH="$HOME/miniconda/envs/test-env/lib:$LIBRARY_PATH"
    export LD_RUN_PATH="$HOME/miniconda/envs/test-env/lib:$LD_RUN_PATH"
    export CPLUS_INCLUDE_PATH="$HOME/miniconda/envs/test-env/include:$AMDAPPSDK/include/:$CPLUS_INCLUDE_PATH"
wxchan's avatar
wxchan committed
15
16
fi

17
18
19
20
21
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
    export CXX=g++-7
    export CC=gcc-7
fi

22
23
LGB_VER=$(head -n 1 VERSION.txt)

24
25
conda create -q -n test-env python=$PYTHON_VERSION
source activate test-env
26

wxchan's avatar
wxchan committed
27
28
cd $TRAVIS_BUILD_DIR

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

wxchan's avatar
wxchan committed
52
if [[ ${TASK} == "pylint" ]]; then
53
    conda install pep8
wxchan's avatar
wxchan committed
54
55
56
57
58
    pep8 --ignore=E501 --exclude=./compute,./docs . || exit -1
    exit 0
fi

if [[ ${TASK} == "if-else" ]]; then
59
    conda install numpy
wxchan's avatar
wxchan committed
60
    mkdir build && cd build && cmake .. && make lightgbm || exit -1
wxchan's avatar
wxchan committed
61
    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
62
63
64
65
66
    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

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

69
if [[ ${TASK} == "sdist" ]]; then
wxchan's avatar
wxchan committed
70
71
72
    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
73
74
    exit 0
elif [[ ${TASK} == "bdist" ]]; then
Guolin Ke's avatar
Guolin Ke committed
75
76
77
78
79
80
    if [[ $TRAVIS_OS_NAME == "osx" ]]; then
        cd $TRAVIS_BUILD_DIR/python-package && python setup.py bdist_wheel --plat-name=macosx --universal || exit -1
        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.whl
    else
        cd $TRAVIS_BUILD_DIR/python-package && python setup.py bdist_wheel --plat-name=manylinux1_x86_64 --universal || exit -1
    fi
81
82
    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
83
84
85
86
87
    exit 0
fi

if [[ ${TASK} == "gpu" ]]; then 
    conda install --yes -c conda-forge boost=1.63.0
88
    if [[ ${METHOD} == "pip" ]]; then
Guolin Ke's avatar
Guolin Ke committed
89
        sed -i 's/const std::string kDefaultDevice = "cpu";/const std::string kDefaultDevice = "gpu";/' ../include/LightGBM/config.h
Guolin Ke's avatar
Guolin Ke committed
90
        cd $TRAVIS_BUILD_DIR/python-package && python setup.py sdist || exit -1
91
        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
92
93
94
        cd $TRAVIS_BUILD_DIR && pytest tests/python_package_test || exit -1
        exit 0
    fi
wxchan's avatar
wxchan committed
95
96
97
98
99
fi

mkdir build && cd build

if [[ ${TASK} == "mpi" ]]; then
100
101
102
    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
103
104
    cmake -DUSE_MPI=ON ..
elif [[ ${TASK} == "gpu" ]]; then
105
    cmake -DUSE_GPU=ON -DBOOST_ROOT="$HOME/miniconda/envs/test-env/" -DOpenCL_INCLUDE_DIR=$AMDAPPSDK/include/ ..
Guolin Ke's avatar
Guolin Ke committed
106
    sed -i 's/const std::string kDefaultDevice = "cpu";/const std::string kDefaultDevice = "gpu";/' ../include/LightGBM/config.h
wxchan's avatar
wxchan committed
107
108
109
110
111
112
113
114
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
115
116
117
118

if [[ ${TASK} == "regular" ]]; then
    cd $TRAVIS_BUILD_DIR/examples/python-guide && python simple_example.py && python sklearn_example.py && python advanced_example.py || exit -1
fi