From 86433df26ff88a12b9164f58fb266c228a37e931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Tr=C4=99bski?= Date: Wed, 12 Jul 2017 13:56:59 +0200 Subject: [PATCH] Tweaks in tox.ini to speed it up Reworked several environments where installing of the package (monasca-log-api) is not necessary. Also added validating all bash files with bashate for the devstack plugin part. Change-Id: I02bd5bfcc3bfbdfda30bc9b6bcc977b37c6c3674 --- test-requirements.txt | 1 + tools/bashate.sh | 6 ++++++ tox.ini | 50 ++++++++++++++++++++++++++----------------- 3 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 tools/bashate.sh diff --git a/test-requirements.txt b/test-requirements.txt index 663ed432..3452069e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,6 +5,7 @@ # Install bounded pep8/pyflakes first, then let flake8 install hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 bandit>=1.1.0 # Apache-2.0 +bashate>=0.2 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD coverage!=4.4,>=4.0 # Apache-2.0 diff --git a/tools/bashate.sh b/tools/bashate.sh new file mode 100644 index 00000000..33d5bebb --- /dev/null +++ b/tools/bashate.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Ignore too long lines error E006 from bashate and treat +# E005, E042 as errors. +SH_FILES=$(find $1 -type d -name files -prune -o -type f -name '*.sh' -print) +bashate -v -iE006 -eE005,E042 ${SH_FILES:-''} diff --git a/tox.ini b/tox.ini index 815975dd..e89d5c08 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = py{27,35},pep8,cover -minversion = 2.1 +minversion = 2.7 skipsdist = True [testenv] @@ -8,12 +8,8 @@ usedevelop = True setenv = VIRTUAL_ENV={envdir} OS_TEST_PATH=monasca_log_api/tests CLIENT_NAME=monasca-log-api -passenv = http_proxy - HTTP_PROXY - https_proxy - HTTPS_PROXY - no_proxy - NO_PROXY +passenv = *_proxy + *_PROXY whitelist_externals = bash find rm @@ -54,33 +50,35 @@ commands = [testenv:bashate] description = Validates (pep8-like) devstack plugins -deps = bashate -whitelist_externals = bashate -commands = - # Ignore too long lines error E006 from bashate and treat - # E005, E042 as errors. - bashate -v -iE006 -eE005,E042 {toxinidir}/devstack/plugin.sh +skip_install = True +usedevelop = False +commands = bash {toxinidir}/tools/bashate.sh {toxinidir}/devstack [testenv:bandit] +description = Validates codebase with bandit +skip_install = True +usedevelop = False commands = # FIXME(dmllr); B101 needs to be fixed first bandit -r monasca_log_api -n5 -s B101 -x monasca_log_api/tests -[testenv:flake8] -commands = - flake8 monasca_log_api - [testenv:pep8] description = Runs set of linters against codebase (flake8, bandit, bashate, checkniceness) -deps = - {[testenv]deps} - {[testenv:bashate]deps} commands = + {[testenv]commands} {[testenv:flake8]commands} {[testenv:bandit]commands} {[testenv:bashate]commands} {[testenv:checkniceness]commands} +[testenv:flake8] +description = Validates codebase with flake +skip_install = True +usedevelop = False +commands = + {[testenv]commands} + flake8 monasca_log_api + [testenv:genconfig] description = Generates sample documentation file for monasca-log-api commands = oslo-config-generator --config-file=config-generator/monasca-log-api.conf @@ -88,6 +86,7 @@ commands = oslo-config-generator --config-file=config-generator/monasca-log-api. [testenv:docs] description = Builds api-ref, api-guide, releasenotes and devdocs commands = + {[testenv]commands} {[testenv:devdocs]commands} {[testenv:api-guide]commands} {[testenv:api-ref]commands} @@ -96,6 +95,7 @@ commands = [testenv:api-guide] description = Called from CI scripts to test and publish the API Guide commands = + {[testenv]commands} rm -rf api-guide/build {[testenv:checkjson]commands} sphinx-build -W -b html -d api-guide/build/doctrees api-guide/source api-guide/build/html @@ -103,6 +103,7 @@ commands = [testenv:api-ref] description = Called from CI scripts to test and publish the API Ref commands = + {[testenv]commands} rm -rf api-ref/build {[testenv:checkjson]commands} sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html @@ -116,6 +117,7 @@ commands = [testenv:devdocs] description = Builds developer documentation commands = + {[testenv]commands} rm -rf doc/build rm -rf doc/source/contributor/api {[testenv:checkjson]commands} @@ -123,7 +125,10 @@ commands = [testenv:checkniceness] description = Validates (pep-like) documenation +skip_install = True +usedevelop = False commands = + {[testenv]commands} doc8 --file-encoding utf-8 {toxinidir}/doc doc8 --file-encoding utf-8 {toxinidir}/api-ref doc8 --file-encoding utf-8 {toxinidir}/api-guide @@ -131,11 +136,16 @@ commands = [testenv:checkjson] description = Validates all json samples inside doc folder +skip_install = True +usedevelop = False deps = whitelist_externals = bash python + find + rm commands = + {[testenv]commands} bash -c "! find doc/ -type f -name *.json | xargs grep -U -n $'\r'" bash -c '! find doc/ -type f -name *.json | xargs -t -n1 python -m json.tool 2>&1 > /dev/null | grep -B1 -v ^python'