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
This commit is contained in:
Andreas Jaeger 2014-08-16 14:54:22 +02:00
parent 175e79ebf7
commit 94849df097
6 changed files with 41 additions and 23 deletions

View File

@ -92,7 +92,7 @@ fi
source $CONF_FILE source $CONF_FILE
if [[ -z $(declare -p BOOKS 2> /dev/null | grep 'declare -A BOOKS') || \ 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 -z $DOC_DIR ]]; then
echo "Error: the configuration file '$CONF_FILE' is invalid" echo "Error: the configuration file '$CONF_FILE' is invalid"
exit 1 exit 1

View File

@ -12,6 +12,6 @@ rm -f working.tar.bz2
touch working/.placeholder touch working/.placeholder
tar cjf working.tar.bz2 working tar cjf working.tar.bz2 working
vagrant package \ vagrant package \
--output=openstack-manuals-$version.box \ --output=openstack-manuals-$version.box \
--vagrantfile=Vagrantfile.box \ --vagrantfile=Vagrantfile.box \
--include working.tar.bz2 --include working.tar.bz2

View File

@ -6,11 +6,11 @@ set -x
# to build the documents. # to build the documents.
for repository in $(ls -d -1 /home/vagrant/repositories/*); do for repository in $(ls -d -1 /home/vagrant/repositories/*); do
cd $repository cd $repository
for document in $(find . -name pom.xml); do for document in $(find . -name pom.xml); do
pushd ${document%/*}; pushd ${document%/*};
mvn clean generate-sources mvn clean generate-sources
mvn clean mvn clean
popd popd
done done
done done

View File

@ -1,27 +1,34 @@
#!/bin/bash -ex #!/bin/bash -ex
# Documentation can be submitted in markdown and then converted to docbook # Documentation can be submitted in markdown and then converted to
# so it can be built with the maven plugin. This is used by Jenkins when # docbook so it can be built with the maven plugin. This is used by
# invoking certain docs jobs and the resulting output is made available to maven. # 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 # In case we start doing something more sophisticated with other refs
# later (such as tags). # later (such as tags).
BRANCH=$ZUUL_REFNAME BRANCH=$ZUUL_REFNAME
shopt -s extglob shopt -s extglob
# This function figures out the location of the original script (as opposed to any chain of # This function figures out the location of the original script (as
# symlinks pointing to it). Source: # opposed to any chain of symlinks pointing to it). Source:
# http://muffinresearch.co.uk/archives/2008/10/10/bash-resolving-symlinks-to-shellscripts/ # http://muffinresearch.co.uk/archives/2008/10/10/bash-resolving-symlinks-to-shellscripts/
function resolve_symlink { function resolve_symlink {
SCRIPT=$1 NEWSCRIPT='' SCRIPT=$1 NEWSCRIPT=''
until [ "$SCRIPT" = "$NEWSCRIPT" ]; do 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) cd $(dirname $SCRIPT)
if [ ! "${SCRIPT:0:1}" = '.' ]; then SCRIPT=$(basename $SCRIPT); fi if [ ! "${SCRIPT:0:1}" = '.' ]; then
SCRIPT=$(basename $SCRIPT);
fi
SCRIPT=${NEWSCRIPT:=$SCRIPT} SCRIPT=${NEWSCRIPT:=$SCRIPT}
NEWSCRIPT=$(ls -l $SCRIPT | awk '{ print $NF }') NEWSCRIPT=$(ls -l $SCRIPT | awk '{ print $NF }')
done done
if [ ! "${SCRIPT:0:1}" = '/' ]; then SCRIPT=$PWD/$SCRIPT; fi if [ ! "${SCRIPT:0:1}" = '/' ]; then
SCRIPT=$PWD/$SCRIPT;
fi
echo $(dirname $SCRIPT) echo $(dirname $SCRIPT)
} }
DIR=$(resolve_symlink $0) DIR=$(resolve_symlink $0)
@ -36,10 +43,12 @@ else
exit 1 exit 1
fi fi
# Need to get the file name to insert here so it can be reused for multiple projects # Need to get the file name to insert here so it can be reused for
# Filenames for the known repos that could do this are openstackapi-programming.mdown # multiple projects Filenames for the known repos that could do this
# and images-api-v2.0.md and openstackapi-programming and images-api-v2.0 are the names # are openstackapi-programming.mdown and images-api-v2.0.md and
# for the ID and xml filename. # openstackapi-programming and images-api-v2.0 are the names for the
# ID and xml filename.
FILENAME=$1 FILENAME=$1
FILEPATH=`find ./ -regextype posix-extended -regex ".*${FILENAME}\.(md|markdown|mdown)"` FILEPATH=`find ./ -regextype posix-extended -regex ".*${FILENAME}\.(md|markdown|mdown)"`
DIRPATH=`dirname $FILEPATH` DIRPATH=`dirname $FILEPATH`

View File

@ -1,3 +1,4 @@
bashate >= 0.2
doc8 doc8
# Hacking already pins down pep8, pyflakes and flake8 # Hacking already pins down pep8, pyflakes and flake8
hacking>=0.9.2,<0.10 hacking>=0.9.2,<0.10

View File

@ -18,6 +18,14 @@ commands =
# HACKING.rst is the only file that is not referenced from # HACKING.rst is the only file that is not referenced from
# doc/source, so add it explicitely. # doc/source, so add it explicitely.
doc8 -e txt -e rst doc/source/ HACKING.rst 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] [testenv:pylint]
commands = pylint os_doc_tools cleanup commands = pylint os_doc_tools cleanup