Unverified Commit 6d7f1da3 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[ci] added test for parameters consistency (#1520)

* added parameters consistency test

* less if statements at Travis

* fixed js emulation command and changing device_type on macOS
parent 8061581e
......@@ -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
......@@ -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
......
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment