network/tox.ini
Jiri Kucera 2c79fad96f Add black wrapper
Some system roles want not to run black on their code. This wrapper
decides whether to run black or not depending on content of config.sh.
This wrapper also allows to set patterns of files and directories via
config.sh to be processed or skipped by black.
2020-01-13 11:57:13 +01:00

254 lines
5.9 KiB
INI

# SPDX-License-Identifier: MIT
[tox]
envlist =
black, pylint, flake8,
py{26,27,36,37,38},
custom
skipsdist = true
skip_missing_interpreters = true
[testenv]
basepython = python3
# List common dependencies for Python interpreters here:
deps =
py{26,27,36,37,38}: pytest-cov
py{27,36,37,38}: pytest>=3.5.1
py{26,27}: mock
py26: pytest
[base]
system_python = /usr/bin/python3
passenv = *
setenv =
PYTHONPATH = {toxinidir}/library:{toxinidir}/module_utils
LC_ALL = C
changedir = {toxinidir}/tests
covtargets = --cov={toxinidir}/library --cov={toxinidir}/module_utils
pytesttarget = unit
whitelist_externals =
bash
runpytest = {toxinidir}/.travis/runpytest.sh
[testenv:py26]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.6}
install_command =
pip install {opts} {packages}
list_dependencies_command =
pip freeze
basepython = python2.6
passenv = {[base]passenv}
setenv =
{[base]setenv}
changedir = {[base]changedir}
whitelist_externals =
{[base]whitelist_externals}
commands =
bash {[base]runpytest} {envpython} \
--durations=5 \
{[base]covtargets} \
--cov-report=html:htmlcov-py26 \
--cov-report=term \
{posargs} \
{[base]pytesttarget}
[testenv:py27]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7}
basepython = python2.7
passenv = {[base]passenv}
setenv =
{[base]setenv}
changedir = {[base]changedir}
whitelist_externals =
{[base]whitelist_externals}
commands =
bash {[base]runpytest} {envpython} \
--durations=5 \
{[base]covtargets} \
--cov-report=html:htmlcov-py27 \
--cov-report=term \
{posargs} \
{[base]pytesttarget}
[testenv:py36]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:3.6}
basepython = python3.6
passenv = {[base]passenv}
setenv =
{[base]setenv}
changedir = {[base]changedir}
whitelist_externals =
{[base]whitelist_externals}
commands =
bash {[base]runpytest} {envpython} \
--durations=5 \
{[base]covtargets} \
--cov-report=html:htmlcov-py36 \
--cov-report=term \
{posargs} \
{[base]pytesttarget}
[testenv:py37]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:3.7}
basepython = python3.7
passenv = {[base]passenv}
setenv =
{[base]setenv}
changedir = {[base]changedir}
whitelist_externals =
{[base]whitelist_externals}
commands =
bash {[base]runpytest} {envpython} \
--durations=5 \
{[base]covtargets} \
--cov-report=html:htmlcov-py37 \
--cov-report=term \
{posargs} \
{[base]pytesttarget}
[testenv:py38]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:3.8}
basepython = python3.8
passenv = {[base]passenv}
setenv =
{[base]setenv}
changedir = {[base]changedir}
whitelist_externals =
{[base]whitelist_externals}
commands =
bash {[base]runpytest} {envpython} \
--durations=5 \
{[base]covtargets} \
--cov-report=html:htmlcov-py38 \
--cov-report=term \
{posargs} \
{[base]pytesttarget}
[testenv:black]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:3.6}
basepython = python3.6
passenv = RUN_BLACK_*
deps =
black
whitelist_externals =
{[base]whitelist_externals}
commands =
bash {toxinidir}/.travis/runblack.sh {envpython} --check --diff .
[testenv:pylint]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7}
basepython = python2.7
passenv = RUN_PYLINT_*
setenv =
{[base]setenv}
deps =
colorama
pylint>=1.8.4
ansible
-rpylint_extra_requirements.txt
commands =
{envpython} ./run_pylint.py --errors-only {posargs}
[testenv:flake8]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7}
basepython = python2.7
deps =
flake8>=3.5
whitelist_externals = flake8
commands =
flake8 --statistics {posargs} .
[testenv:coveralls]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:coveralls}
passenv = TRAVIS TRAVIS_*
whitelist_externals = bash
deps =
coveralls
changedir = {[base]changedir}
commands =
bash -c 'cd ..; bash .travis/fix-coverage.sh; cd -'
coveralls
# LSR_MOLECULE_DEPS may contain aditional Molecule dependencies. For example,
# in `network` system role, LSR_MOLECULE_DEPS can be set as
#
# LSR_MOLECULE_DEPS='-rmolecule_requirements.txt'
#
# where `molecule_requirements.txt` contains two lines:
#
# jmespath
# selinux
#
[molecule_common]
deps =
docker
molecule
{env:LSR_MOLECULE_DEPS:}
[testenv:molecule_lint]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
deps =
{[molecule_common]deps}
commands_pre =
molecule --version
ansible --version
commands =
molecule lint -s {env:LSR_MSCENARIO:default} {posargs}
[testenv:molecule_syntax]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
deps =
{[molecule_common]deps}
commands =
molecule syntax -s {env:LSR_MSCENARIO:default} {posargs}
[testenv:molecule_test]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
deps =
{[molecule_common]deps}
commands =
molecule test -s {env:LSR_MSCENARIO:default} {posargs}
[testenv:molecule]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
deps =
{[molecule_common]deps}
commands_pre =
{[testenv:molecule_lint]commands_pre}
commands =
{[testenv:molecule_lint]commands}
{[testenv:molecule_syntax]commands}
{[testenv:molecule_test]commands}
[testenv:custom]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:custom}
deps =
-rcustom_requirements.txt
passenv = *
whitelist_externals =
{[base]whitelist_externals}
commands =
bash {toxinidir}/.travis/custom.sh {envpython} {[base]system_python}
[pytest]
addopts = -rxs
[flake8]
show_source = true
max-line-length = 88
ignore = E402,W503
[pylint]
max-line-length = 88
disable = wrong-import-position
[pycodestyle]
max-line-length = 88
[travis]
python =
2.6: py26,custom
2.7: py27,flake8,pylint,custom
3.5: coveralls,molecule,custom
3.6: py36,black,custom
3.7: py37,custom
3.8: py38,custom