Jesse Pretorius fef4571fb4 Revise all lint tests and add consolidated 'linters' tox environment
OpenStack-Infra has requested that lint tests be pipelined into the 'linters'
tox target in order to make more efficient use of nodepool resources.

This patch:

- Ensures that a complete set of lints tests is available in individual
  tox targets.
- Adds a 'linters' target which executes all the other lints tests.
- Removes our own custom scripts which used to facilitate lint tests
  through the old script-based style.
- Updates documentation that relates to lint testing and does a fair bit
  of revision to the dev docs related to testing and gating.

Notes:
- The E005, E006 exceptions for the bashate check will be removed in subsequent
  patches along with fixes that resolve those errors.

Change-Id: I7e090f325e07012de208c45bce8a6a9d9e241289
2016-02-01 16:52:51 +00:00

117 lines
3.3 KiB
INI

[tox]
minversion = 1.6
skipsdist = True
envlist = docs,linters,releasenotes
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
[testenv:releasenotes]
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:docs]
commands=
python setup.py build_sphinx
# environment used by the -infra templated docs job
[testenv:venv]
deps = -r{toxinidir}/test-requirements.txt
commands = {posargs}
# Run hacking/flake8 check for all python files
[testenv:pep8]
deps = flake8
whitelist_externals = bash
commands =
bash -c "grep -Irl \
-e '!/usr/bin/env python' \
-e '!/bin/python' \
-e '!/usr/bin/python' \
--exclude-dir '.*' \
--exclude-dir 'doc' \
--exclude-dir '*.egg' \
--exclude-dir '*.egg-info' \
--exclude-dir '*templates' \
--exclude 'tox.ini' \
--exclude '*.sh' \
{toxinidir} | xargs flake8 --verbose"
[flake8]
# Ignores the following rules due to how ansible modules work in general
# F403 'from ansible.module_utils.basic import *' used;
# unable to detect undefined names
# H303 No wildcard (*) import.
ignore=F403,H303
[testenv:bashate]
deps =
bashate
whitelist_externals = bash
commands =
# Run bashate check for all bash scripts
# Ignores the following rules:
# E003: Indent not multiple of 4 (we prefer to use multiples of 2)
# E005: File does not begin with #! or have .sh prefix
# E006: Line longer than 79 columns
bash -c "grep -Irl \
-e '!/usr/bin/env bash' \
-e '!/bin/bash' \
-e '!/bin/sh' \
--exclude-dir '.*' \
--exclude-dir '*.egg' \
--exclude-dir '*.egg-info' \
--exclude 'tox.ini' \
{toxinidir} | xargs bashate --verbose --ignore=E003,E005,E006"
[testenv:ansible-lint]
deps =
ansible>1.9,<2.0
ansible-lint
whitelist_externals = bash
commands =
# Perform an Ansible lint check
bash -c "ansible-lint {toxinidir}/playbooks/*.yml"
[testenv:ansible-syntax]
deps =
ansible>1.9,<2.0
whitelist_externals = bash
commands =
# Perform an Ansible syntax check
bash -c "mkdir -p {envtmpdir}/ansible; \
export ANSIBLE_CONFIG={envtmpdir}/ansible/ansible.cfg; \
export ANSIBLE_ROLES_PATH={envtmpdir}/ansible/roles; \
sed 's|/etc/ansible|{envtmpdir}/ansible|' \
{toxinidir}/tests/ansible.cfg | \
tee {envtmpdir}/ansible/ansible.cfg; \
sed 's|path: /etc/ansible|path: {envtmpdir}/ansible|' \
{toxinidir}/ansible-role-requirements.yml | \
tee {envtmpdir}/ansible/ansible-role-requirements.yml; \
ansible-galaxy install \
--role-file={envtmpdir}/ansible/ansible-role-requirements.yml \
--roles-path={envtmpdir}/ansible/roles \
--ignore-errors \
--force; \
ansible-playbook -i 'localhost ansible-connection=local,' \
--syntax-check \
--list-tasks \
{toxinidir}/playbooks/*.yml"
[testenv:linters]
deps =
{[testenv:pep8]deps}
{[testenv:bashate]deps}
{[testenv:ansible-lint]deps}
# note that the ansible-syntax deps are omitted on purpose as the
# ansible-lint env contains duplicate items in its dep list
whitelist_externals = bash
commands =
{[testenv:pep8]commands}
{[testenv:bashate]commands}
{[testenv:ansible-lint]commands}
{[testenv:ansible-syntax]commands}