Debian Codegraph @

ansible_collections/amazon/aws/tox.ini

raw
1 # It would be nice to merge this into pyproject.toml, unfortunately as of 4.23.2 they don't support generative environments when using TOML
2
3 [tox]
4 skipsdist = True
5 skip_missing_interpreters = True
6 envlist =
7 ansible{2.17}-py{310,311,312}-{with_constraints,without_constraints}
8 ansible{2.18,2.19}-py{311,312,313}-{with_constraints,without_constraints}
9 ansible{2.20}-py{312,313,314}-{with_constraints,without_constraints}
10
11 [common]
12 collection_name = amazon.aws
13 collection_path = amazon/aws
14
15 format_dirs = {toxinidir}/plugins {toxinidir}/tests
16 lint_dirs = {toxinidir}/plugins {toxinidir}/tests
17
18 ansible_desc =
19 ansible2.17: Ansible-core 2.17
20 ansible2.18: Ansible-core 2.18
21 ansible2.19: Ansible-core 2.19
22 ansible2.20: Ansible-core 2.20
23 const_desc =
24 with_constraints: (With boto3/botocore constraints)
25
26 ansible_home = {envtmpdir}/ansible_home
27 ansible_collections_path = {[common]ansible_home}/collections
28 full_collection_path = {[common]ansible_home}/collections/ansible_collections/{[common]collection_path}
29
30 [testenv]
31 description = Run the unit tests {[common]ansible_desc}/{base_python} {[common]const_desc}
32 set_env =
33 ANSIBLE_HOME={[common]ansible_home}
34 ANSIBLE_COLLECTIONS_PATH={[common]ansible_collections_path}
35 # ansible_pytest_collections is more aggressive than pytest_ansible when injecting collections into the import path
36 # not needed if unit tests are under tests/unit/plugins rather than directly under tests/unit
37 # ANSIBLE_CONTROLLER_MIN_PYTHON_VERSION=3.11
38 # PYTEST_PLUGINS=ansible_test._util.target.pytest.plugins.ansible_pytest_collections
39 labels = unit
40 deps =
41 pytest
42 mock
43 pytest-mock
44 pytest-cov
45 pytest-ansible
46 pytest-xdist
47 -rtest-requirements.txt
48 -rtests/unit/requirements.txt
49 ansible2.17: ansible-core>2.17,<2.18
50 ansible2.18: ansible-core>2.18,<2.19
51 ansible2.19: ansible-core>2.19,<2.20
52 ansible2.20: ansible-core>2.20,<2.21
53 with_constraints: -rtests/unit/constraints.txt
54 allowlist_externals = rsync
55 change_dir = {[common]full_collection_path}
56 commands_pre =
57 rsync --delete --exclude=.tox -qraugpo {toxinidir}/ {[common]full_collection_path}/
58 ansible-galaxy collection install git+https://github.com/ansible-collections/community.aws.git,stable-11
59 commands =
60 pytest \
61 --cov \
62 --cov-report html \
63 --cov-report xml \
64 --ansible-host-pattern localhost \
65 {posargs:tests/unit/}
66
67 [testenv:clean]
68 description = Remove test results and caches
69 allowlist_externals = rm, find
70 deps = coverage
71 skip_install = true
72 change_dir = {toxinidir}
73 commands_pre =
74 commands =
75 coverage erase
76 find .tox -name coverage.xml -delete
77 rm -rf tests/output/ htmlcov/ .mypy_cache/ complexity/ .ruff_cache/
78
79 [testenv:complexity-report]
80 labels = future-lint
81 description = Generate a HTML complexity report in the complexity directory
82 deps =
83 flake8-pyproject
84 flake8-html
85 change_dir = {toxinidir}
86 commands_pre =
87 commands =
88 -flake8 \
89 --select C90 \
90 --max-complexity 10 \
91 --format=html \
92 --htmldir={posargs:complexity} \
93 {posargs:{[common]lint_dirs}}
94
95 [testenv:ansible-lint]
96 labels = lint
97 description = Run ansible-lint
98 deps =
99 ansible-lint >= 25.1.2
100 jmespath
101 change_dir = {toxinidir}
102 commands_pre =
103 commands =
104 ansible-lint \
105 --skip-list=name[missing],yaml[line-length],args[module],run-once[task],ignore-errors,sanity[cannot-ignore],run-once[play] \
106 {posargs:{[common]lint_dirs}}
107
108 [testenv:black]
109 labels = format
110 description = Apply "black" formatting
111 depends =
112 flynt, isort
113 deps =
114 black >=23.0, <24.0
115 change_dir = {toxinidir}
116 commands_pre =
117 commands =
118 black {posargs:{[common]format_dirs}}
119
120 [testenv:black-lint]
121 labels = lint
122 description = Lint against "black" formatting standards
123 deps =
124 {[testenv:black]deps}
125 change_dir = {toxinidir}
126 commands_pre =
127 commands =
128 black --check --diff {posargs:{[common]format_dirs}}
129
130 [testenv:isort]
131 labels = format
132 description = Sort imports
133 deps =
134 isort
135 change_dir = {toxinidir}
136 commands_pre =
137 commands =
138 isort {posargs:{[common]format_dirs}}
139
140 [testenv:isort-lint]
141 labels = lint
142 description = Lint for import sorting
143 deps =
144 {[testenv:isort]deps}
145 change_dir = {toxinidir}
146 commands_pre =
147 commands =
148 isort --check-only --diff {posargs:{[common]format_dirs}}
149
150 [testenv:flynt]
151 labels = format
152 description = Apply flint (f-string) formatting
153 deps =
154 flynt
155 change_dir = {toxinidir}
156 commands_pre =
157 commands =
158 flynt {posargs:{[common]format_dirs}}
159
160 [testenv:flynt-lint]
161 labels = lint
162 description = Run flint (f-string) linting
163 deps =
164 flynt
165 change_dir = {toxinidir}
166 commands_pre =
167 commands =
168 flynt --dry-run --fail-on-change {posargs:{[common]format_dirs}}
169
170 [testenv:flake8-lint]
171 labels = lint
172 description = Run FLAKE8 linting
173 deps =
174 flake8
175 flake8-pyproject
176 change_dir = {toxinidir}
177 commands_pre =
178 commands =
179 flake8 {posargs:{[common]format_dirs}}
180
181 [testenv:pylint-lint]
182 labels = lint
183 description = Run pylint tests that are disabled by the default Ansible sanity tests
184 deps =
185 pylint
186 change_dir = {toxinidir}
187 commands_pre =
188 commands =
189 pylint \
190 --disable R,C,W,E \
191 --enable pointless-statement \
192 --enable consider-using-dict-items \
193 --enable assignment-from-no-return \
194 --enable no-else-continue \
195 --enable no-else-break \
196 --enable simplifiable-if-statement \
197 --enable pointless-string-statement \
198 --enable redefined-outer-name \
199 --enable redefined-builtin \
200 --enable unused-import \
201 {posargs:{[common]lint_dirs}}
202
203 [testenv:ruff]
204 description = lint source code
205 labels = format-future
206 deps =
207 ruff
208 change_dir = {toxinidir}
209 commands_pre =
210 commands =
211 ruff check --fix {posargs:{[common]lint_dirs}}
212 ruff format {posargs:{[common]lint_dirs}}
213
214 [testenv:ruff-lint]
215 description = lint source code
216 labels = lint-future
217 deps =
218 ruff
219 change_dir = {toxinidir}
220 commands_pre =
221 commands =
222 ruff check --diff --unsafe-fixes {posargs:{[common]lint_dirs}}
223 ruff check {posargs:{[common]lint_dirs}}
224
225 [testenv:ansible-lint-future]
226 labels = future-lint
227 description = Run ansible-lint
228 deps =
229 ansible-lint
230 jmespath
231 git+https://github.com/ansible/ansible.git@devel
232 shellcheck-py
233 commands =
234 ansible-lint \
235 {posargs:{[common]lint_dirs}}
236
237 [testenv:ansible-sanity]
238 labels = future-lint
239 description = Run latest (devel) Ansible sanity tests
240 deps =
241 git+https://github.com/ansible/ansible.git@devel
242 shellcheck-py
243 commands =
244 ansible-test sanity
245
246 [testenv:mypy-lint]
247 allowlist_externals = rsync,ln
248 labels = future-lint
249 description = Run mypi type tests
250 set_env =
251 ANSIBLE_HOME={[common]ansible_home}
252 ANSIBLE_COLLECTIONS_PATH={[common]ansible_collections_path}
253 MYPYPATH={[common]ansible_home}
254 deps =
255 mypy
256 # ansible-core
257 git+https://github.com/ansible/ansible.git@devel
258 botocore
259 boto3
260 placebo
261 typing_extensions
262 commands_pre =
263 rsync --delete --exclude=.tox -qraugpo {toxinidir}/ {[common]full_collection_path}/
264 ansible-galaxy collection install git+https://github.com/ansible-collections/community.aws.git
265 ln -s {env_site_packages_dir}/ansible {[common]ansible_collections_path}/ansible
266 ln -s {[common]ansible_home}/collections/ansible_collections {[common]ansible_home}/ansible_collections
267 commands =
268 # TODO: passing directories doesn't work well, it's better to pass the package
269 # we might want to consider manipulating posargs/directories into the package names
270 mypy \
271 --check-untyped-defs \
272 --namespace-packages --explicit-package-bases \
273 --follow-imports silent \
274 -p ansible_collections.amazon.aws.plugins.plugin_utils \
275 -p ansible_collections.amazon.aws.plugins.module_utils