From 1021611d3ea0ae50d29ca47053c487aa13e587ec Mon Sep 17 00:00:00 2001 From: tqchen Date: Thu, 21 May 2020 10:48:12 -0700 Subject: [PATCH 1/2] [CI] Add log check to the sphinx gallery docs This PR add log check to sphinx gallery tutorials to prevent the case when sphinx failed to capture the error in tutorials. --- tests/scripts/task_python_docs.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/scripts/task_python_docs.sh b/tests/scripts/task_python_docs.sh index eaa705d65849..42dc0a486279 100755 --- a/tests/scripts/task_python_docs.sh +++ b/tests/scripts/task_python_docs.sh @@ -20,6 +20,17 @@ set -e set -u source tests/scripts/setup-pytest-env.sh + +cleanup() +{ + # cat error log if non zero exit + if [ $? ]; then + cat /tmp/$$.log.txt + fi + rm -rf /tmp/$$.* +} +trap cleanup 0 + # cleanup old states rm -rf docs/_build mkdir -p docs/_build/html @@ -36,7 +47,11 @@ find . -type f -path "*.pyc" | xargs rm -f make cython3 cd docs -PYTHONPATH=`pwd`/../python make html +PYTHONPATH=`pwd`/../python make html 2>/tmp/$$.log.txt +if grep -E "failed to execute" < /tmp/$$.log.txt; then + echo "Some of sphinx-gallery item example failed to execute." + exit 1 +fi cd .. # C++ doc From d38c57a2f9e9d50d2b500c0b73dee2326f662cdb Mon Sep 17 00:00:00 2001 From: tqchen Date: Thu, 21 May 2020 15:06:29 -0700 Subject: [PATCH 2/2] Fix the status --- tests/scripts/task_python_docs.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/scripts/task_python_docs.sh b/tests/scripts/task_python_docs.sh index 42dc0a486279..be2d7920026a 100755 --- a/tests/scripts/task_python_docs.sh +++ b/tests/scripts/task_python_docs.sh @@ -23,11 +23,7 @@ source tests/scripts/setup-pytest-env.sh cleanup() { - # cat error log if non zero exit - if [ $? ]; then - cat /tmp/$$.log.txt - fi - rm -rf /tmp/$$.* + rm -rf /tmp/$$.log.txt } trap cleanup 0 @@ -50,6 +46,7 @@ cd docs PYTHONPATH=`pwd`/../python make html 2>/tmp/$$.log.txt if grep -E "failed to execute" < /tmp/$$.log.txt; then echo "Some of sphinx-gallery item example failed to execute." + cat /tmp/$$.log.txt exit 1 fi cd ..