[CI] Add log check to the sphinx gallery docs (#5643)
authorTianqi Chen <tqchen@users.noreply.github.com>
Fri, 22 May 2020 01:37:58 +0000 (18:37 -0700)
committerGitHub <noreply@github.com>
Fri, 22 May 2020 01:37:58 +0000 (18:37 -0700)
* [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.

* Fix the status

tests/scripts/task_python_docs.sh

index eaa705d..be2d792 100755 (executable)
@@ -20,6 +20,13 @@ set -e
 set -u
 
 source tests/scripts/setup-pytest-env.sh
+
+cleanup()
+{
+    rm -rf /tmp/$$.log.txt
+}
+trap cleanup 0
+
 # cleanup old states
 rm -rf docs/_build
 mkdir -p docs/_build/html
@@ -36,7 +43,12 @@ 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."
+    cat /tmp/$$.log.txt
+    exit 1
+fi
 cd ..
 
 # C++ doc