From 4a54fe9681e6748c626be3ad83bc851451107643 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Mon, 30 Sep 2013 21:18:48 +0200 Subject: [PATCH] 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 --- build-ha-guide.sh | 25 +++++++++++++++++++++ test.py | 57 +++++++++++++++++++++++++++++++++++++++++------ validate.py | 56 ++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 124 insertions(+), 14 deletions(-) create mode 100755 build-ha-guide.sh diff --git a/build-ha-guide.sh b/build-ha-guide.sh new file mode 100755 index 00000000..d3e5582a --- /dev/null +++ b/build-ha-guide.sh @@ -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, bk-ha-guide.xml diff --git a/test.py b/test.py index d7a1d892..9c3db7b7 100755 --- a/test.py +++ b/test.py @@ -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: diff --git a/validate.py b/validate.py index 7d37940e..8a4ec3fb 100755 --- a/validate.py +++ b/validate.py @@ -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: