-
Notifications
You must be signed in to change notification settings - Fork 1
/
tox.ini
114 lines (100 loc) · 2.77 KB
/
tox.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
[tox]
# do not build the distribution package
skipsdist = True
# default list of test environments
envlist = clean,ansible{2.12,2.13}-py{38,39,310},linters
# Tox4 supports labels which allow us to group the environments
# rather than dumping all commands into a single environment
labels =
# grouping for formatting environments
format = flynt, black, isort
# grouping for linting environments
lint = complexity-report, ansible-lint, black-lint, isort-lint, flake8-lint, flynt-lint
# grouping for unit test environments
units = ansible{2.12,2.13}-py{38,39,310}
[common]
# common directories for formatting, is the root of the collection
format_dirs = {toxinidir}/plugins {toxinidir}/tests
[testenv]
description = Run the test-suite and generate an HTML coverage report
deps =
pytest
pytest-cov
ansible2.12: ansible-core>2.12,<2.13
ansible2.13: ansible-core>2.13,<2.14
!ansible2.12-!ansible2.13: ansible-core
pytest-ansible
-rtest-requirements.txt
commands = pytest --cov-report html --cov plugins/module_utils --cov plugins/modules plugins {posargs:tests/}
[testenv:clean]
deps = coverage
skip_install = true
commands = coverage erase
[testenv:complexity-report]
description = Generate a HTML complexity report in the complexity directory
deps =
# See: https://github.com/lordmauve/flake8-html/issues/30
flake8>=3.3.0,<5.0.0
flake8-html
commands = -flake8 --select C90 --max-complexity 10 --format=html --htmldir={posargs:complexity} plugins
[testenv:ansible-lint]
deps =
ansible-lint
commands =
ansible-lint {toxinidir}/plugins
[testenv:black]
depends =
flynt, isort
deps =
black >=23.0, <24.0
commands =
black {[common]format_dirs}
[testenv:black-lint]
# Check code formatting with black
deps =
{[testenv:black]deps}
commands =
black -v --check --diff {[common]format_dirs}
[testenv:isort]
# Sort imports with isort
deps =
isort
commands =
isort {[common]format_dirs}
[testenv:isort-lint]
deps =
{[testenv:isort]deps}
commands =
isort --check-only --diff {[common]format_dirs}
[testenv:flake8-lint]
deps =
flake8
commands =
flake8 {posargs} {[common]format_dirs}
[testenv:flynt]
deps =
flynt
commands =
flynt {[common]format_dirs}
[testenv:flynt-lint]
deps =
flynt
commands =
flynt --dry-run --fail-on-change {[common]format_dirs}
[testenv:linters]
# Run linters black, isort, and flake8
deps =
{[testenv:black]deps}
{[testenv:isort]deps}
flake8
commands =
black -v --check {toxinidir}/plugins {toxinidir}/tests
isort --check-only --diff {toxinidir}/plugins {toxinidir}/tests
flake8 {posargs} {toxinidir}/plugins {toxinidir}/tests
[flake8]
# Configuration for flake8
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125,E203,E402,E501,E741,F401,F811,F841,W503
max-line-length = 160
builtins = _