From 94849df09725c215242403d38376182561c9d684 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Sat, 16 Aug 2014 14:54:22 +0200 Subject: [PATCH] Fix issues found by bashate and include in gating Cleanup shell scripts to pass bashate testing. Add bashate check to pep8 check target. Change-Id: I49b9ab1e352378a43f82a4e1f5db02a8dae99d27 --- bin/doc-tools-check-languages | 2 +- build_environment/bin/package.sh | 6 ++--- build_environment/files/fetch.sh | 14 +++++----- os_doc_tools/scripts/markdown-docbook.sh | 33 +++++++++++++++--------- test-requirements.txt | 1 + tox.ini | 8 ++++++ 6 files changed, 41 insertions(+), 23 deletions(-) diff --git a/bin/doc-tools-check-languages b/bin/doc-tools-check-languages index 7cf4e09d..85627d0c 100755 --- a/bin/doc-tools-check-languages +++ b/bin/doc-tools-check-languages @@ -92,7 +92,7 @@ fi source $CONF_FILE if [[ -z $(declare -p BOOKS 2> /dev/null | grep 'declare -A BOOKS') || \ - -z $(declare -p DIRECTORIES 2> /dev/null | grep 'declare -A DIRECTORIES') || \ + -z $(declare -p DIRECTORIES 2> /dev/null | grep 'declare -A DIRECTORIES') || \ -z $DOC_DIR ]]; then echo "Error: the configuration file '$CONF_FILE' is invalid" exit 1 diff --git a/build_environment/bin/package.sh b/build_environment/bin/package.sh index 984aa35e..2e2c1ca7 100755 --- a/build_environment/bin/package.sh +++ b/build_environment/bin/package.sh @@ -12,6 +12,6 @@ rm -f working.tar.bz2 touch working/.placeholder tar cjf working.tar.bz2 working vagrant package \ - --output=openstack-manuals-$version.box \ - --vagrantfile=Vagrantfile.box \ - --include working.tar.bz2 + --output=openstack-manuals-$version.box \ + --vagrantfile=Vagrantfile.box \ + --include working.tar.bz2 diff --git a/build_environment/files/fetch.sh b/build_environment/files/fetch.sh index d06acbf9..a83af861 100644 --- a/build_environment/files/fetch.sh +++ b/build_environment/files/fetch.sh @@ -6,11 +6,11 @@ set -x # to build the documents. for repository in $(ls -d -1 /home/vagrant/repositories/*); do - cd $repository - for document in $(find . -name pom.xml); do - pushd ${document%/*}; - mvn clean generate-sources - mvn clean - popd - done + cd $repository + for document in $(find . -name pom.xml); do + pushd ${document%/*}; + mvn clean generate-sources + mvn clean + popd + done done diff --git a/os_doc_tools/scripts/markdown-docbook.sh b/os_doc_tools/scripts/markdown-docbook.sh index ec36b75e..229e4814 100755 --- a/os_doc_tools/scripts/markdown-docbook.sh +++ b/os_doc_tools/scripts/markdown-docbook.sh @@ -1,27 +1,34 @@ #!/bin/bash -ex -# Documentation can be submitted in markdown and then converted to docbook -# so it can be built with the maven plugin. This is used by Jenkins when -# invoking certain docs jobs and the resulting output is made available to maven. +# Documentation can be submitted in markdown and then converted to +# docbook so it can be built with the maven plugin. This is used by +# Jenkins when invoking certain docs jobs and the resulting output is +# made available to maven. # In case we start doing something more sophisticated with other refs # later (such as tags). BRANCH=$ZUUL_REFNAME shopt -s extglob -# This function figures out the location of the original script (as opposed to any chain of -# symlinks pointing to it). Source: +# This function figures out the location of the original script (as +# opposed to any chain of symlinks pointing to it). Source: # http://muffinresearch.co.uk/archives/2008/10/10/bash-resolving-symlinks-to-shellscripts/ function resolve_symlink { SCRIPT=$1 NEWSCRIPT='' until [ "$SCRIPT" = "$NEWSCRIPT" ]; do - if [ "${SCRIPT:0:1}" = '.' ]; then SCRIPT=$PWD/$SCRIPT; fi + if [ "${SCRIPT:0:1}" = '.' ]; then + SCRIPT=$PWD/$SCRIPT; + fi cd $(dirname $SCRIPT) - if [ ! "${SCRIPT:0:1}" = '.' ]; then SCRIPT=$(basename $SCRIPT); fi + if [ ! "${SCRIPT:0:1}" = '.' ]; then + SCRIPT=$(basename $SCRIPT); + fi SCRIPT=${NEWSCRIPT:=$SCRIPT} NEWSCRIPT=$(ls -l $SCRIPT | awk '{ print $NF }') done - if [ ! "${SCRIPT:0:1}" = '/' ]; then SCRIPT=$PWD/$SCRIPT; fi + if [ ! "${SCRIPT:0:1}" = '/' ]; then + SCRIPT=$PWD/$SCRIPT; + fi echo $(dirname $SCRIPT) } DIR=$(resolve_symlink $0) @@ -36,10 +43,12 @@ else exit 1 fi -# Need to get the file name to insert here so it can be reused for multiple projects -# Filenames for the known repos that could do this are openstackapi-programming.mdown -# and images-api-v2.0.md and openstackapi-programming and images-api-v2.0 are the names -# for the ID and xml filename. +# Need to get the file name to insert here so it can be reused for +# multiple projects Filenames for the known repos that could do this +# are openstackapi-programming.mdown and images-api-v2.0.md and +# openstackapi-programming and images-api-v2.0 are the names for the +# ID and xml filename. + FILENAME=$1 FILEPATH=`find ./ -regextype posix-extended -regex ".*${FILENAME}\.(md|markdown|mdown)"` DIRPATH=`dirname $FILEPATH` diff --git a/test-requirements.txt b/test-requirements.txt index 6c1ff0c8..1c17b175 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ +bashate >= 0.2 doc8 # Hacking already pins down pep8, pyflakes and flake8 hacking>=0.9.2,<0.10 diff --git a/tox.ini b/tox.ini index 816966e3..f0bcf38f 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,14 @@ commands = # HACKING.rst is the only file that is not referenced from # doc/source, so add it explicitely. doc8 -e txt -e rst doc/source/ HACKING.rst + # Run bashate during pep8 runs to ensure violations are caught by + # the check and gate queues. + bashate autogenerate_config_docs/autohelp-wrapper \ + autogenerate_config_docs/test/genconfs.sh \ + bin/doc-tools-check-languages \ + build_environment/files/fetch.sh build_environment/bin/package.sh \ + cleanup/remove_trailing_whitespaces.sh \ + os_doc_tools/scripts/markdown-docbook.sh [testenv:pylint] commands = pylint os_doc_tools cleanup