Last active
July 19, 2018 01:55
-
-
Save logan2211/c5f38423b085fbea78392f1ee10700d5 to your computer and use it in GitHub Desktop.
Ansible role testing tox.ini
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[tox] | |
minversion = 2.0 | |
skipsdist = True | |
envlist = linters,functional_2.3,functional_2.4,functional_stable | |
[testenv] | |
usedevelop = True | |
deps = | |
-r{toxinidir}/test-requirements.txt | |
commands = | |
/usr/bin/find . -type f -name "*.pyc" -delete | |
passenv = | |
HOME | |
http_proxy | |
HTTP_PROXY | |
https_proxy | |
HTTPS_PROXY | |
no_proxy | |
NO_PROXY | |
ANSIBLE_FORCE_COLOR | |
docker_image | |
docker_image_tag | |
docker_command | |
INVENTORY_FILE | |
whitelist_externals = | |
bash | |
git | |
rm | |
wget | |
setenv = | |
VIRTUAL_ENV={envdir} | |
INVENTORY_FILE={env:INVENTORY_FILE:inventory} | |
# environment used by the -infra templated docs job | |
[testenv:venv] | |
# NOTE(jaegerandi): this target does not use constraints because | |
# upstream infra does not yet support it. Once that's fixed, we can | |
# drop the install_command. | |
install_command = | |
pip install -U {opts} {packages} | |
commands = | |
{posargs} | |
[testenv:pep8] | |
commands = | |
# Run hacking/flake8 check for all python files | |
bash -c "grep --recursive --binary-files=without-match \ | |
--files-with-match '^.!.*python$' \ | |
--exclude-dir .eggs \ | |
--exclude-dir .git \ | |
--exclude-dir .tox \ | |
--exclude-dir *.egg-info \ | |
--exclude-dir doc \ | |
{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] | |
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) | |
# 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 \ | |
--files-with-match '^.!.*\(ba\)\?sh$' \ | |
--exclude-dir .tox \ | |
--exclude-dir .git \ | |
{toxinidir} | xargs bashate --error . --verbose --ignore=E003,E006,E040" | |
[testenv:ansible] | |
deps = | |
{[testenv]deps} | |
setenv = | |
{[testenv]setenv} | |
ANSIBLE_HOST_KEY_CHECKING = False | |
ANSIBLE_SSH_CONTROL_PATH = /tmp/%%h-%%r | |
# This is required as the default is '/etc/ansible/roles' or a path | |
# specified in ansible.cfg | |
ANSIBLE_ROLES_PATH = {homedir}/.ansible/roles:{toxinidir}/.. | |
commands = | |
rm -rf {homedir}/.ansible/roles | |
bash -c "if [[ -f {toxinidir}/ansible-role-requirements.yml ]]; then \ | |
ansible-galaxy install \ | |
--role-file={toxinidir}/ansible-role-requirements.yml \ | |
--force; \ | |
fi" | |
[testenv:ansible_2.2] | |
deps = | |
{[testenv:ansible]deps} | |
ansible>=2.2,<2.3 | |
setenv = | |
{[testenv:ansible]setenv} | |
commands = | |
{[testenv:ansible]commands} | |
[testenv:ansible_2.3] | |
deps = | |
{[testenv:ansible]deps} | |
ansible>=2.3,<2.4 | |
setenv = | |
{[testenv:ansible]setenv} | |
commands = | |
{[testenv:ansible]commands} | |
[testenv:ansible_2.4] | |
deps = | |
{[testenv:ansible]deps} | |
ansible>=2.4,<2.5 | |
setenv = | |
{[testenv:ansible]setenv} | |
commands = | |
{[testenv:ansible]commands} | |
[testenv:ansible_2.5] | |
deps = | |
{[testenv:ansible]deps} | |
ansible>=2.5,<2.6 | |
setenv = | |
{[testenv:ansible]setenv} | |
commands = | |
{[testenv:ansible]commands} | |
[testenv:ansible_stable] | |
deps = | |
{[testenv:ansible]deps} | |
ansible | |
setenv = | |
{[testenv:ansible]setenv} | |
commands = | |
{[testenv:ansible]commands} | |
[testenv:ansible-syntax] | |
deps = | |
{[testenv:ansible_stable]deps} | |
setenv = | |
{[testenv:ansible_stable]setenv} | |
commands = | |
{[testenv:ansible_stable]commands} | |
ansible-playbook -i {toxinidir}/tests/inventory \ | |
--syntax-check \ | |
--list-tasks \ | |
-e "rolename={toxinidir}" \ | |
{toxinidir}/tests/test.yml | |
[testenv:ansible-lint] | |
deps = | |
{[testenv:ansible_stable]deps} | |
ansible-lint | |
commands = | |
ansible-lint {toxinidir} | |
[testenv:functional_base] | |
install_command = | |
pip install -U {opts} {packages} | |
deps = | |
{[testenv:ansible_stable]deps} | |
setenv = | |
{[testenv:ansible_stable]setenv} | |
commands = | |
ansible-playbook -i {toxinidir}/tests/{env:INVENTORY_FILE} \ | |
-e "rolename={toxinidir}" \ | |
{toxinidir}/tests/test.yml | |
[testenv:functional_2.2] | |
install_command = | |
{[testenv:functional_base]install_command} | |
deps = | |
{[testenv:ansible_2.2]deps} | |
setenv = | |
{[testenv:ansible_2.2]setenv} | |
commands = | |
{[testenv:ansible_2.2]commands} | |
{[testenv:functional_base]commands} | |
[testenv:functional_2.3] | |
install_command = | |
{[testenv:functional_base]install_command} | |
deps = | |
{[testenv:ansible_2.3]deps} | |
setenv = | |
{[testenv:ansible_2.3]setenv} | |
commands = | |
{[testenv:ansible_2.3]commands} | |
{[testenv:functional_base]commands} | |
[testenv:functional_2.4] | |
install_command = | |
{[testenv:functional_base]install_command} | |
deps = | |
{[testenv:ansible_2.4]deps} | |
setenv = | |
{[testenv:ansible_2.4]setenv} | |
commands = | |
{[testenv:ansible_2.4]commands} | |
{[testenv:functional_base]commands} | |
[testenv:functional_2.5] | |
install_command = | |
{[testenv:functional_base]install_command} | |
deps = | |
{[testenv:ansible_2.5]deps} | |
setenv = | |
{[testenv:ansible_2.5]setenv} | |
commands = | |
{[testenv:ansible_2.5]commands} | |
{[testenv:functional_base]commands} | |
[testenv:functional_stable] | |
install_command = | |
{[testenv:functional_base]install_command} | |
deps = | |
{[testenv:ansible_stable]deps} | |
setenv = | |
{[testenv:ansible_stable]setenv} | |
commands = | |
{[testenv:ansible_stable]commands} | |
{[testenv:functional_base]commands} | |
[testenv:linters] | |
deps = | |
{[testenv:ansible-lint]deps} | |
setenv = | |
{[testenv:ansible_stable]setenv} | |
commands = | |
{[testenv:pep8]commands} | |
{[testenv:bashate]commands} | |
{[testenv:ansible-lint]commands} | |
{[testenv:ansible-syntax]commands} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment