Update tox config and add bashate E006, E040 exceptions

This patch updates the tox.ini the same bashate exceptions as are
currently in the OpenStack-Ansible playbook repo.

It also ensures that the linters and all lint targets work
appropriately and normalises the tox.ini configuration to use
uniform formatting.

Change-Id: I2e76678eb79ec4a52a7cce74997f59e005aee283
This commit is contained in:
Jesse Pretorius 2016-02-12 11:52:08 +00:00
parent 1e999b9256
commit 5c4df7b608
2 changed files with 38 additions and 35 deletions

View File

@ -1,5 +1,5 @@
ansible-lint bashate
ansible>=1.9.1,<2.0.0 flake8
# this is required for the docs build jobs # this is required for the docs build jobs
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2

49
tox.ini
View File

@ -3,38 +3,41 @@ minversion = 1.6
skipsdist = True skipsdist = True
envlist = docs,linters envlist = docs,linters
[testenv] [testenv]
usedevelop = True usedevelop = True
install_command = pip install -U {opts} {packages} install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt deps = -r{toxinidir}/test-requirements.txt
commands = /usr/bin/find . -type f -name "*.pyc" -delete
passenv =
HOME
whitelist_externals =
bash
setenv =
VIRTUAL_ENV={envdir}
[testenv:docs] [testenv:docs]
commands= commands=
python setup.py build_sphinx python setup.py build_sphinx
# environment used by the -infra templated docs job # environment used by the -infra templated docs job
[testenv:venv] [testenv:venv]
deps = -r{toxinidir}/test-requirements.txt deps = -r{toxinidir}/test-requirements.txt
commands = {posargs} commands = {posargs}
[testenv:pep8] [testenv:pep8]
deps =
flake8
whitelist_externals = bash
commands = commands =
# Run hacking/flake8 check for all python files # Run hacking/flake8 check for all python files
bash -c "grep -Irl \ bash -c "grep --recursive --binary-files=without-match \
-e '!/usr/bin/env python' \ --files-with-match '^.!.*python$' \
-e '!/bin/python' \ --exclude-dir .eggs \
-e '!/usr/bin/python' \ --exclude-dir .git \
--exclude-dir '.*' \ --exclude-dir .tox \
--exclude-dir 'doc' \ --exclude-dir *.egg-info \
--exclude-dir '*.egg' \ --exclude-dir doc \
--exclude-dir '*.egg-info' \
--exclude-dir '*templates' \
--exclude 'tox.ini' \
--exclude '*.sh' \
{toxinidir} | xargs flake8 --verbose" {toxinidir} | xargs flake8 --verbose"
[flake8] [flake8]
@ -44,25 +47,25 @@ commands =
# H303 No wildcard (*) import. # H303 No wildcard (*) import.
ignore=F403,H303 ignore=F403,H303
[testenv:bashate] [testenv:bashate]
deps =
bashate
whitelist_externals = bash
commands = commands =
# Run bashate check for all bash scripts # Run bashate check for all bash scripts
# Ignores the following rules: # Ignores the following rules:
# E003: Indent not multiple of 4 (we prefer to use multiples of 2) # E003: Indent not multiple of 4 (we prefer to use multiples of 2)
# E006: Line longer than 79 columns (as many scripts use jinja
# templating, this is very difficult)
# E040: Syntax error determined using `bash -n` (as many scripts
# use jinja templating, this will often fail and the syntax
# error will be discovered in execution anyway)
bash -c "grep --recursive --binary-files=without-match \ bash -c "grep --recursive --binary-files=without-match \
--files-with-match '^.!.*\(ba\)\?sh$' \ --files-with-match '^.!.*\(ba\)\?sh$' \
--exclude-dir .tox \ --exclude-dir .tox \
--exclude-dir .git \ --exclude-dir .git \
{toxinidir} | xargs bashate --error . --verbose --ignore=E003" {toxinidir} | xargs bashate --error . --verbose --ignore=E003,E006,E040"
[testenv:linters] [testenv:linters]
deps =
{[testenv:pep8]deps}
{[testenv:bashate]deps}
whitelist_externals = bash
commands = commands =
{[testenv:pep8]commands} {[testenv:pep8]commands}
{[testenv:bashate]commands} {[testenv:bashate]commands}