kayobe/tox.ini
Mark Goddard 76309988ff Initial unit testing of ansible - kolla-ansible role
Adds a new tox environment, ansible, which runs ansible unit tests. One
such test has been implemented so far, for the kolla-ansible role.
2017-12-07 11:26:50 +00:00

84 lines
2.5 KiB
INI

[tox]
minversion = 2.0
envlist = py34,py27,pypy,pep8
skipsdist = True
[testenv]
usedevelop = True
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike} {opts} {packages}
passenv =
HOME
whitelist_externals =
bash
setenv =
VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
TESTS_DIR=./kayobe/tests/unit/
deps = -r{toxinidir}/test-requirements.txt
commands = unit2 discover {posargs}
[testenv:pep8]
commands =
flake8 {posargs} kayobe
# Check the *.rst files
# We use a thin wrapper around doc8 currently, which has support for sphinx
# directives. We install sphinx 1.5.x because versions prior to this
# (installed due to upper constraints) automatically import all
# sphinx.directive.* modules when any one of those modules is imported, and
# importing sphinx.directive.other breaks docutils parsing.
pip install -U sphinx<1.6
{toxinidir}/tools/sphinx8 README.rst CONTRIBUTING.rst doc/source --ignore D001
[testenv:venv]
commands = {posargs}
[testenv:docs]
commands = python setup.py build_sphinx
[testenv:debug]
commands = oslo_debug_helper {posargs}
[testenv:ansible]
usedevelop = True
# Create the virtualenv with access to system site packages, as this is
# required to use the python and apt modules, which are not available via PyPI.
sitepackages = True
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike} {opts} {packages}
commands =
bash -c \
"ansible-playbook \
--connection=local \
{toxinidir}/ansible/roles/*/tests/main.yml \
{posargs}"
[testenv:alint]
commands = ansible-lint ansible/*.yaml
[testenv:ansible-syntax]
commands =
# Install ansible role dependencies from Galaxy.
ansible-galaxy install \
-r {toxinidir}/requirements.yml \
-p {toxinidir}/ansible/roles
# Perform an Ansible syntax check. Skip some playbooks which require extra
# variables to be defined.
bash -c \
"ansible-playbook \
--connection=local \
--syntax-check \
--list-tasks \
$(find {toxinidir}/ansible \
-maxdepth 1 \
-name '*.yml' \
-not -name idrac-bootstrap-one.yml \
-not -name idrac-bootstrap.yml) \
{posargs}"
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build