diff --git a/doc-test.conf b/doc-test.conf new file mode 100644 index 00000000..cf0c045c --- /dev/null +++ b/doc-test.conf @@ -0,0 +1,6 @@ +[DEFAULT] +repo_name = security-doc + +# Repository is not under doc, thus we need to set api_site to True. +api_site = True + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..af50c06d --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +openstack-doc-tools>=0.15 diff --git a/tools/test-languages.sh b/tools/test-languages.sh new file mode 100755 index 00000000..f16a25d2 --- /dev/null +++ b/tools/test-languages.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +function setup_directory { + SET_LANG=$1 + shift + for BOOK_DIR in "$@" ; do + echo " $BOOK_DIR" + openstack-generate-docbook -l $SET_LANG -b $BOOK_DIR -r ./ + done +} + + +function setup_lang { + SET_LANG=$1 + shift + echo "Setting up files for $SET_LANG" + echo "=======================" + echo " Directories:" + setup_directory $SET_LANG 'security-guide' +} + +function test_security_guide { + SET_LANG=$1 + shift + setup_lang "$SET_LANG" + + case "$PURPOSE" in + test) + openstack-doc-test -v --check-build -l "$SET_LANG" \ + --only-book security-guide + RET=$? + ;; + publish) + openstack-doc-test -v --publish --check-build "$SET_LANG" \ + --only-book security-guide + RET=$? + ;; + esac + if [ "$RET" -eq "0" ] ; then + echo "... succeeded" + else + echo "... failed" + BUILD_FAIL=1 + fi +} + +function test_language () { + + case "$language" in + all) + test_security_guide "ja" + ;; + ja) + test_security_guide "$language" + ;; + *) + BUILD_FAIL=1 + echo "Language $language not handled" + ;; + esac +} + +function usage () { + echo "Call the script as: " + echo "$0 PURPOSE LANGUAGE1 LANGUAGE2..." + echo "PURPOSE is either 'test', 'publish' or 'publish-install'" + echo "LANGUAGE can also be 'all'." +} + +if [ "$#" -lt 2 ] ; then + usage + exit 1 +fi +if [ "$1" = "test" ] ; then + PURPOSE="test" +elif [ "$1" = "publish" ] ; then + PURPOSE="publish" +else + usage + exit 1 +fi +shift +BUILD_FAIL=0 +for language in "$@" ; do + echo + echo "Building for language $language" + echo + test_language "$language" +done + +exit $BUILD_FAIL diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..94e8c617 --- /dev/null +++ b/tox.ini @@ -0,0 +1,68 @@ +[tox] +minversion = 1.6 +envlist = checkniceness,checksyntax,checkdeletions,checkbuild +skipsdist = True + +[testenv] +setenv = + VIRTUAL_ENV={envdir} +deps = -r{toxinidir}/test-requirements.txt +whitelist_externals = + bash + cp + mkdir + rm + sed + +[testenv:venv] +commands = {posargs} + +[testenv:checkniceness] +commands = openstack-doc-test --check-niceness {posargs} + +[testenv:checksyntax] +commands = + openstack-doc-test --check-syntax {posargs} + # Check that .po and .pot files are valid: + bash -c "find security-guide -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null" + +[testenv:checkdeletions] +commands = openstack-doc-test --check-deletions {posargs} + +[testenv:checkbuild] +commands = openstack-doc-test --check-build {posargs} + +[testenv:publishdocs] +# Prepare all documents so that they can get published on +# docs.openstack.org with just copying publish-docs/* over. +commands = + # Create directory, it might not be here if openstack-doc-test does + # not publish anything. + mkdir publish-docs + # We only publish changed manuals. + openstack-doc-test --check-build --publish + +[testenv:checklang] +# Generatedocbook needs xml2po which cannot be installed +# in the venv. Since it's installed in the system, let's +# use sitepackages. +sitepackages=True +whitelist_externals = bash +commands = bash tools/test-languages.sh test ja + +[testenv:buildlang] +# Run as "tox -e buildlang -- $LANG" +# Generatedocbook needs xml2po which cannot be installed +# in the venv. Since it's installed in the system, let's +# use sitepackages. +sitepackages=True +whitelist_externals = bash +commands = bash tools/test-languages.sh publish {posargs} + +[testenv:publishlang] +# Generatedocbook needs xml2po which cannot be installed +# in the venv. Since it's installed in the system, let's +# use sitepackages. +sitepackages=True +whitelist_externals = bash +commands = bash tools/test-languages.sh publish all