Skip to content

Commit

Permalink
[ci] added test for parameters consistency (#1520)
Browse files Browse the repository at this point in the history
* added parameters consistency test

* less if statements at Travis

* fixed js emulation command and changing device_type on macOS
  • Loading branch information
StrikerRUS committed Jul 15, 2018
1 parent 8061581 commit 6d7f1da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
18 changes: 12 additions & 6 deletions .travis/test.sh
Expand Up @@ -11,25 +11,31 @@ source activate test-env
cd $TRAVIS_BUILD_DIR

if [[ $TASK == "check-docs" ]]; then
if [[ $TRAVIS_OS_NAME != "osx" ]]; then
sudo apt-get install linkchecker
fi
if [[ ${PYTHON_VERSION} == "2.7" ]]; then
if [[ $PYTHON_VERSION == "2.7" ]]; then
conda install mock
fi
conda install sphinx "sphinx_rtd_theme>=0.3" # html5validator
pip install rstcheck
# check reStructuredText formatting
cd $TRAVIS_BUILD_DIR/python-package
rstcheck --report warning `find . -type f -name "*.rst"` || exit -1
cd $TRAVIS_BUILD_DIR/docs
rstcheck --report warning --ignore-directives=autoclass,autofunction `find . -type f -name "*.rst"` || exit -1
# build docs and check them for broken links
make html || exit -1
find ./_build/html/ -type f -name '*.html' -exec \
sed -i -e 's;\(\.\/[^.]*\.\)rst\([^[:space:]]*\);\1html\2;g' {} \; # emulate js function
sed -i'.bak' -e 's;\(\.\/[^.]*\.\)rst\([^[:space:]]*\);\1html\2;g' {} \; # emulate js function
# html5validator --root ./_build/html/ || exit -1
if [[ $TRAVIS_OS_NAME != "osx" ]]; then
sudo apt-get install linkchecker
linkchecker --config=.linkcheckerrc ./_build/html/*.html || exit -1
fi
# check the consistency of parameters' descriptions and other stuff
cp $TRAVIS_BUILD_DIR/docs/Parameters.rst $TRAVIS_BUILD_DIR/docs/Parameters-backup.rst
cp $TRAVIS_BUILD_DIR/src/io/config_auto.cpp $TRAVIS_BUILD_DIR/src/io/config_auto-backup.cpp
python $TRAVIS_BUILD_DIR/helper/parameter_generator.py || exit -1
diff $TRAVIS_BUILD_DIR/docs/Parameters-backup.rst $TRAVIS_BUILD_DIR/docs/Parameters.rst || exit -1
diff $TRAVIS_BUILD_DIR/src/io/config_auto-backup.cpp $TRAVIS_BUILD_DIR/src/io/config_auto.cpp || exit -1
exit 0
fi

Expand Down Expand Up @@ -69,7 +75,7 @@ fi

if [[ $TASK == "gpu" ]]; then
conda install --yes -c conda-forge boost
sed -i 's/std::string device_type = "cpu";/std::string device_type = "gpu";/' $TRAVIS_BUILD_DIR/include/LightGBM/config.h
sed -i'.bak' 's/std::string device_type = "cpu";/std::string device_type = "gpu";/' $TRAVIS_BUILD_DIR/include/LightGBM/config.h
grep -q 'std::string device_type = "gpu"' $TRAVIS_BUILD_DIR/include/LightGBM/config.h || exit -1 # make sure that changes were really done
if [[ $METHOD == "pip" ]]; then
cd $TRAVIS_BUILD_DIR/python-package && python setup.py sdist || exit -1
Expand Down
7 changes: 4 additions & 3 deletions helper/parameter_generator.py
Expand Up @@ -222,8 +222,9 @@ def GenParameterCode(config_hpp, config_out_cpp):


if __name__ == "__main__":
config_hpp = os.path.join(os.path.pardir, 'include', 'LightGBM', 'config.h')
config_out_cpp = os.path.join(os.path.pardir, 'src', 'io', 'config_auto.cpp')
params_rst = os.path.join(os.path.pardir, 'docs', 'Parameters.rst')
current_dir = os.path.abspath(os.path.dirname(__file__))
config_hpp = os.path.join(current_dir, os.path.pardir, 'include', 'LightGBM', 'config.h')
config_out_cpp = os.path.join(current_dir, os.path.pardir, 'src', 'io', 'config_auto.cpp')
params_rst = os.path.join(current_dir, os.path.pardir, 'docs', 'Parameters.rst')
sections, descriptions = GenParameterCode(config_hpp, config_out_cpp)
GenParameterDescription(sections, descriptions, params_rst)

0 comments on commit 6d7f1da

Please sign in to comment.