ci: Add CI job for building the documentation draft
authorBoris Feld <boris.feld@octobus.net>
Wed, 18 Dec 2019 14:10:49 +0100
changeset 5227 b24de4b465ea
parent 5226 38d225efcea9
child 5228 cfabc3c4aa10
ci: Add CI job for building the documentation
.gitlab-ci.yml
docs/tutorial/mypandocfilters/raw-file.py
docs/tutorial/prepare.sh
docs/tutorial/prepare_pandoc.sh
docs/tutorial/prepare_test_file.sh
docs/tutorial/testlib/pythonpath.sh
--- a/.gitlab-ci.yml	Fri Nov 22 18:56:42 2019 +0100
+++ b/.gitlab-ci.yml	Wed Dec 18 14:10:49 2019 +0100
@@ -36,12 +36,22 @@
         - (cd tests; python3 /ci/repos/mercurial/tests/run-tests.py --color=always --pure)
 
 doc:
-    image: octobus/ci-py2-evolve-doc
+    image: octobus/ci-py2-evolve-tutorial-doc
     script:
-        - cd docs/
+        # Run the documentation test file in Python 2
+        - cd docs/tutorial
+        # Install some dependencies for the test file
+        - ./prepare_test_file.sh
+        - python /ci/repos/mercurial/tests/run-tests.py test-training.t
+        # But run the documentation generation in Python3
+        - python3 -m venv .venv
+        - source .venv/bin/activate
+        # Install some dependencies for the doc generation
+        - ./prepare_pandoc.sh
+        - cd ..
+        # Sphinx is installed globally outside and runs with Python2 but
+        # pandoc is launching filters with current Python, which is Python 3
         - make
-    variables:
-        LANG: en_us.UTF-8
     artifacts:
         paths:
             - html/*
--- a/docs/tutorial/mypandocfilters/raw-file.py	Fri Nov 22 18:56:42 2019 +0100
+++ b/docs/tutorial/mypandocfilters/raw-file.py	Wed Dec 18 14:10:49 2019 +0100
@@ -16,8 +16,8 @@
         return pf.RawBlock('<pre>%s</pre>' % content, "html")
         # elem.text = content
 
-def main(doc=None):
-    return pf.run_filter(action, doc=doc)
+def main():
+    pf.toJSONFilter(action=action)
 
 
 if __name__ == '__main__':
--- a/docs/tutorial/prepare.sh	Fri Nov 22 18:56:42 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-
-# Prepare pandoc filters
-if [ -d pandocfilters/.git ]; then
-    (cd pandocfilters && git remote update && git merge --ff-only)
-else
-    git clone https://github.com/Lothiraldan/pandocfilters.git
-fi
-
-pip2 install pandocfilters
-pip2 install pygraphviz
-pip2 install panflute
-pip2 install hg+https://bitbucket.org/octobus/mercurial_docgraph
-pip2 install hg-evolve
-
-mkdir -p graphs output
-
-CMD_NOT_FOUND=0
-check_command() {
-    cmd=$1
-    if ! which "$cmd" >/dev/null 2>&1; then
-        echo "Error: command '$cmd' not found in \$PATH"
-        echo "Please install '$cmd'"
-        CMD_NOT_FOUND=1
-    else
-        echo "$cmd command was found"
-    fi
-}
-
-check_command pandoc
-check_command aha
-
-if [ "$CMD_NOT_FOUND" -ne "0" ]; then
-    exit 1
-fi
-
-# Prepare directory for repositories generated by the training.t file
-mkdir -p base-repos
-
-rm -Rf base-repos/*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/tutorial/prepare_pandoc.sh	Wed Dec 18 14:10:49 2019 +0100
@@ -0,0 +1,32 @@
+#!/bin/bash
+set -euo pipefail
+
+# Prepare pandoc filters
+if [ -d pandocfilters/.git ]; then
+    (cd pandocfilters && git remote update && git merge --ff-only)
+else
+    git clone https://github.com/octobus-net/pandocfilters.git
+fi
+
+# Dependencies for pandoc and its filters itself
+python -m pip install pandocfilters
+python -m pip install panflute
+python -m pip install pygraphviz
+
+CMD_NOT_FOUND=0
+check_command() {
+    cmd=$1
+    if ! which "$cmd" >/dev/null 2>&1; then
+        echo "Error: command '$cmd' not found in \$PATH"
+        echo "Please install '$cmd'"
+        CMD_NOT_FOUND=1
+    else
+        echo "$cmd command was found"
+    fi
+}
+
+check_command pandoc
+
+if [ "$CMD_NOT_FOUND" -ne "0" ]; then
+    exit 1
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/tutorial/prepare_test_file.sh	Wed Dec 18 14:10:49 2019 +0100
@@ -0,0 +1,30 @@
+#!/bin/bash
+set -euo pipefail
+
+# Dependencies for the testfile
+python -m pip install hg-docgraph
+
+mkdir -p graphs output
+
+CMD_NOT_FOUND=0
+check_command() {
+    cmd=$1
+    if ! which "$cmd" >/dev/null 2>&1; then
+        echo "Error: command '$cmd' not found in \$PATH"
+        echo "Please install '$cmd'"
+        CMD_NOT_FOUND=1
+    else
+        echo "$cmd command was found"
+    fi
+}
+
+check_command aha
+
+if [ "$CMD_NOT_FOUND" -ne "0" ]; then
+    exit 1
+fi
+
+# Prepare directory for repositories generated by the training.t file
+mkdir -p base-repos
+
+rm -Rf base-repos/*
--- a/docs/tutorial/testlib/pythonpath.sh	Fri Nov 22 18:56:42 2019 +0100
+++ b/docs/tutorial/testlib/pythonpath.sh	Wed Dec 18 14:10:49 2019 +0100
@@ -1,9 +1,14 @@
 # utility to setup pythonpath to point into the tested repository
 
-export SRCDIR=`dirname $TESTDIR`
+SRCDIR=$(dirname "$(dirname "$TESTDIR")");
+export SRCDIR;
 if [ -n "$PYTHONPATH" ]; then
     export HGTEST_ORIG_PYTHONPATH=$PYTHONPATH
-    export PYTHONPATH=$SRCDIR:$PYTHONPATH
+    if uname -o | grep -q Msys; then
+        export PYTHONPATH="$SRCDIR;$PYTHONPATH"
+    else
+        export PYTHONPATH=$SRCDIR:$PYTHONPATH
+    fi
 else
     export PYTHONPATH=$SRCDIR
 fi