Build all Install Guides and HA Guide in gates

Build books the same way we build them for publishing:

Build all three variants of the Install Guides if we check building.
Since we introduce os specific sections, the guide might build for one
variant but not the others.

In case of failure, the variant is shown like:
Building all queued 1 books now...
>>> Build of book install-guide (for Ubuntu) failed (returncode = 1).

Also, generate the xml file for the HA guide and build it.

Add generated file bk-ha-guide.xml to .gitignore

Add parameter -B for building to mvn to silence download progress

Run test.py and validate.py through pep8 and fix any issues

Change-Id: Icfb4587e7c08050d1b65dddc5a3a810a8bf12f5a
This commit is contained in:
Andreas Jaeger 2013-09-30 21:18:48 +02:00
parent 1c26b1d4d0
commit 4a54fe9681
3 changed files with 124 additions and 14 deletions

25
build-ha-guide.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# This script needs to be called from the doc/high-availibilty-guide
# directory!
# Find location of db4-upgrade-xsl:
if [ -e /usr/share/xml/docbook/stylesheet/docbook5/db4-upgrade.xsl ] ; then
DB_UPGRADE=/usr/share/xml/docbook/stylesheet/docbook5/db4-upgrade.xsl
elif [ -e /usr/share/xml/docbook/stylesheet/upgrade/db4-upgrade.xsl ] ; then
DB_UPGRADE=/usr/share/xml/docbook/stylesheet/upgrade/db4-upgrade.xsl
else
echo "db4-upgrade.xsl not found"
exit 1
fi
type -P asciidoc > /dev/null 2>&1 || { echo >&2 "asciidoc not installed. Aborting."; exit 1; }
type -P xsltproc > /dev/null 2>&1 || { echo >&2 "xsltproc not installed. Aborting."; exit 1; }
type -P xmllint > /dev/null 2>&1 || { echo >&2 "xmllint not installed. Aborting."; exit 1; }
asciidoc -b docbook -d book -o - ha-guide.txt | \
xsltproc -o - $DB_UPGRADE - | \
xmllint --format - | \
sed -e 's,<book,<book xml:id="bk-ha-guide",' | \
sed -e 's,<info,<?rax pdf.url="../openstack-ha-guide-trunk.pdf"?><info,' \
> bk-ha-guide.xml

57
test.py
View File

@ -363,24 +363,66 @@ def logging_build_book(result):
def build_book(book):
"""Build a single book"""
"""Build book(s) in directory book"""
os.chdir(book)
result = True
returncode = 0
base_book = os.path.basename(book)
try:
shutil.rmtree(os.path.expanduser("~/.fop"),
ignore_errors=True)
# Clean first and then build so that the output of all guides
# is available
output = subprocess.check_output(
["mvn", "clean", "generate-sources"],
["mvn", "clean"],
stderr=subprocess.STDOUT
)
if base_book == "install-guide":
# Build Fedora
base_book = "install-guide (for Fedora)"
output = subprocess.check_output(
["mvn", "generate-sources", "-B",
"-Doperating.system=yum",
"-Dprofile.os='centos;fedora;rhel'"],
stderr=subprocess.STDOUT
)
# Build openSUSE
base_book = "install-guide (for openSUSE)"
output = subprocess.check_output(
["mvn", "generate-sources", "-B",
"-Doperating.system=zypper", "-Dprofile.os=opensuse"],
stderr=subprocess.STDOUT
)
# Build Ubuntu
base_book = "install-guide (for Ubuntu)"
output = subprocess.check_output(
["mvn", "generate-sources", "-B",
"-Doperating.system=apt", "-Dprofile.os=ubuntu"],
stderr=subprocess.STDOUT
)
# Success
base_book = "install-guide (for Fedora, openSUSE, Ubuntu)"
elif base_book == "high-availability-guide":
output = subprocess.check_output(
["../../tools/build-ha-guide.sh", ],
stderr=subprocess.STDOUT
)
output = subprocess.check_output(
["mvn", "generate-sources", "-B"],
stderr=subprocess.STDOUT
)
else:
output = subprocess.check_output(
["mvn", "generate-sources", "-B"],
stderr=subprocess.STDOUT
)
except subprocess.CalledProcessError as e:
output = e.output
returncode = e.returncode
result = False
return (os.path.basename(book), result, output, returncode)
return (base_book, result, output, returncode)
def build_affected_books(rootdir, book_exceptions, file_exceptions,
@ -435,7 +477,7 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions,
# pom.xml and pom.xml is not checked for
# modification of included files.
doc = etree.parse(path)
# Check for inclusion of files as part of imagedata
for node in doc.findall(
'//{http://docbook.org/ns/docbook}imagedata'):
@ -444,10 +486,10 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions,
os.path.abspath(href) in modified_files):
affected_books.append(book_root)
break
if book_root in affected_books:
break
# Check for inclusion of files as part of xi:include
ns = {"xi": "http://www.w3.org/2001/XInclude"}
for node in doc.xpath('//xi:include', namespaces=ns):
@ -458,7 +500,7 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions,
break
if book_root in affected_books:
break
if not force and affected_books:
books = affected_books
else:
@ -494,6 +536,7 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions,
sys.exit(1)
print("Building finished.")
def main(args):
if args.check_all:

View File

@ -356,24 +356,66 @@ def logging_build_book(result):
def build_book(book):
"""Build a single book"""
"""Build book(s) in directory book"""
os.chdir(book)
result = True
returncode = 0
base_book = os.path.basename(book)
try:
shutil.rmtree(os.path.expanduser("~/.fop"),
ignore_errors=True)
# Clean first and then build so that the output of all guides
# is available
output = subprocess.check_output(
["mvn", "clean", "generate-sources"],
["mvn", "clean"],
stderr=subprocess.STDOUT
)
if base_book == "install-guide":
# Build Fedora
base_book = "install-guide (for Fedora)"
output = subprocess.check_output(
["mvn", "generate-sources", "-B",
"-Doperating.system=yum",
"-Dprofile.os='centos;fedora;rhel'"],
stderr=subprocess.STDOUT
)
# Build openSUSE
base_book = "install-guide (for openSUSE)"
output = subprocess.check_output(
["mvn", "generate-sources", "-B",
"-Doperating.system=zypper", "-Dprofile.os=opensuse"],
stderr=subprocess.STDOUT
)
# Build Ubuntu
base_book = "install-guide (for Ubuntu)"
output = subprocess.check_output(
["mvn", "generate-sources", "-B",
"-Doperating.system=apt", "-Dprofile.os=ubuntu"],
stderr=subprocess.STDOUT
)
# Success
base_book = "install-guide (for Fedora, openSUSE, Ubuntu)"
elif base_book == "high-availability-guide":
output = subprocess.check_output(
["../../tools/build-ha-guide.sh", ],
stderr=subprocess.STDOUT
)
output = subprocess.check_output(
["mvn", "generate-sources", "-B"],
stderr=subprocess.STDOUT
)
else:
output = subprocess.check_output(
["mvn", "generate-sources", "-B"],
stderr=subprocess.STDOUT
)
except subprocess.CalledProcessError as e:
output = e.output
returncode = e.returncode
result = False
return (os.path.basename(book), result, output, returncode)
return (base_book, result, output, returncode)
def build_affected_books(rootdir, book_exceptions, file_exceptions, force):
@ -430,7 +472,7 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions, force):
# was modified (scanning one level only)
doc = etree.parse(path)
# Check for inclusion of files as part of imagedata
for node in doc.findall(
'//{http://docbook.org/ns/docbook}imagedata'):
@ -439,10 +481,10 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions, force):
os.path.abspath(href) in modified_files):
affected_books.append(book_root)
break
if book_root in affected_books:
break
# Check for inclusion of files as part of xi:include
ns = {"xi": "http://www.w3.org/2001/XInclude"}
for node in doc.xpath('//xi:include', namespaces=ns):
@ -453,7 +495,7 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions, force):
break
if book_root in affected_books:
break
if not force and affected_books:
books = affected_books
else: