mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
Other changes: - run linters before tests - return [pylint] and [pycodestyle] back on the list (some IDE's rely on this)
242 lines
5.9 KiB
INI
242 lines
5.9 KiB
INI
[tox]
|
|
envlist =
|
|
black, pylint, flake8,
|
|
py{26,27,36,37,38},
|
|
molecule_{lint,syntax,test},
|
|
extra
|
|
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]
|
|
passenv = *
|
|
setenv =
|
|
PYTHONPATH = {toxinidir}/library:{toxinidir}/module_utils
|
|
LC_ALL = C
|
|
changedir = {toxinidir}/tests
|
|
covtarget = {toxinidir}/library --cov {toxinidir}/module_utils
|
|
pytesttarget = .
|
|
|
|
[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}
|
|
commands =
|
|
pytest --durations=5 \
|
|
--cov={[base]covtarget} \
|
|
--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}
|
|
commands =
|
|
pytest --durations=5 \
|
|
--cov={[base]covtarget} \
|
|
--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}
|
|
commands =
|
|
pytest --durations=5 \
|
|
--cov={[base]covtarget} \
|
|
--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}
|
|
commands =
|
|
pytest --durations=5 \
|
|
--cov={[base]covtarget} \
|
|
--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}
|
|
commands =
|
|
pytest --durations=5 \
|
|
--cov={[base]covtarget} \
|
|
--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
|
|
deps =
|
|
black
|
|
commands =
|
|
black --check --diff --include "^[^.].*\.py$" --exclude "/(\.[^.].*|tests/roles)/" .
|
|
|
|
[testenv:pylint]
|
|
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7}
|
|
basepython = python2.7
|
|
setenv =
|
|
{[base]setenv}
|
|
deps =
|
|
colorama
|
|
pylint>=1.8.4
|
|
ansible
|
|
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:2.7}
|
|
basepython = python2.7
|
|
passenv = TRAVIS TRAVIS_*
|
|
deps =
|
|
coveralls
|
|
changedir = {[base]changedir}
|
|
commands =
|
|
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]
|
|
deps =
|
|
docker
|
|
molecule
|
|
{env:LSR_MOLECULE_DEPS:}
|
|
|
|
[testenv:molecule_lint]
|
|
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
|
|
deps =
|
|
{[molecule]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]deps}
|
|
commands =
|
|
molecule syntax -s {env:LSR_MSCENARIO:default} {posargs}
|
|
|
|
[testenv:molecule_test]
|
|
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
|
|
deps =
|
|
{[molecule]deps}
|
|
commands =
|
|
molecule test -s {env:LSR_MSCENARIO:default} {posargs}
|
|
|
|
# Here we provide a way how a role can add its custom command to be run. Such
|
|
# extra command is run at the end of each testenv run and is driven by
|
|
# environment variables. Involved environment variables are:
|
|
#
|
|
# LSR_TEXTRA_DEPS
|
|
# - contains dependency needed by commands to run smoothly; if more than
|
|
# one dependency is needed, use external file together with '-r' option
|
|
# (see PEP 508)
|
|
#
|
|
# LSR_TEXTRA_DIR
|
|
# - directory to which to cd
|
|
#
|
|
# LSR_TEXTRA_CMD
|
|
# - custom command to be run
|
|
#
|
|
# Example: `network` system role need to run `./tests/ensure_non_running_provider.py`
|
|
# to check for the existence of `*_provider.yml` playbooks. The script
|
|
# is run in Python 3.6.
|
|
#
|
|
# To make this possible, we add to `.travis/config.sh` a snippet:
|
|
#
|
|
# export LSR_TEXTRA_DEPS='PyYAML'
|
|
# export LSR_TEXTRA_DIR='tests'
|
|
# export LSR_TEXTRA_CMD='./ensure_non_running_provider.py'
|
|
#
|
|
[testenv:extra]
|
|
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:extra}
|
|
deps =
|
|
{env:LSR_TEXTRA_DEPS:}
|
|
passenv = *
|
|
changedir = {toxinidir}/{env:LSR_TEXTRA_DIR:.}
|
|
commands =
|
|
{env:LSR_TEXTRA_CMD:python --version}
|
|
|
|
[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,extra
|
|
2.7: py27,coveralls,flake8,pylint,extra
|
|
3.5: molecule_lint,molecule_syntax,molecule_test,extra
|
|
3.6: py36,black,extra
|
|
3.7: py37,extra
|
|
3.8: py38,extra
|