blob: 48c8a85d9689dd7e092dbfd6c4aeb8883381def5 [file] [log] [blame]
Peter Pentchev469dfea2022-06-27 12:48:18 +03001# Operator charm (with zaza): tox.ini
2
3[tox]
4envlist = pep8,py3
5skipsdist = True
6# NOTE: Avoid build/test env pollution by not enabling sitepackages.
7sitepackages = False
8# NOTE: Avoid false positives by not skipping missing interpreters.
9skip_missing_interpreters = False
10# NOTES:
11# * We avoid the new dependency resolver by pinning pip < 20.3, see
12# https://github.com/pypa/pip/issues/9187
13# * Pinning dependencies requires tox >= 3.2.0, see
14# https://tox.readthedocs.io/en/latest/config.html#conf-requires
15# * It is also necessary to pin virtualenv as a newer virtualenv would still
16# lead to fetching the latest pip in the func* tox targets, see
17# https://stackoverflow.com/a/38133283
18# * It is necessary to declare setuptools as a dependency otherwise tox will
19# fail very early at not being able to load it. The version pinning is in
20# line with `pip.sh`.
21requires = pip < 20.3
22 virtualenv < 20.0
23 setuptools < 50.0.0
Peter Pentchev4c577102022-12-08 17:15:51 +020024 tox < 4
Peter Pentchev469dfea2022-06-27 12:48:18 +030025# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci
26minversion = 3.2.0
27
Biser Milanov53644f62022-08-03 16:08:59 +030028[defs]
29pyfiles =
30 src
31 tests
32 unit_tests
Biser Milanovbffa6872022-09-01 11:36:06 +030033func_env_vars =
34 CHARM_SP_PUBLIC_SPACE
35 CHARM_SP_TEMPLATE
36 CHARM_SP_API_HTTP_HOST
37 CHARM_SP_API_HTTP_PORT
38 CHARM_SP_AUTH_TOKEN
39 CHARM_SP_ISCSI_PORTAL_GROUP
40 CHARM_SP_EXTRA_MACHINE_TAGS
Biser Milanov53644f62022-08-03 16:08:59 +030041
Biser Milanov3fc57d72022-09-07 13:04:47 +030042[tools:isort]
43profile = "black"
44
Peter Pentchev469dfea2022-06-27 12:48:18 +030045[testenv]
46setenv = VIRTUAL_ENV={envdir}
47 PYTHONHASHSEED=0
48 CHARM_DIR={envdir}
49install_command =
50 pip install {opts} {packages}
51commands = stestr run --slowest {posargs}
52allowlist_externals =
53 git
54 bash
55 charmcraft
56 rename.sh
57passenv = HOME TERM CS_* OS_* TEST_*
58deps = -r{toxinidir}/test-requirements.txt
59
60[testenv:py35]
61basepython = python3.5
62# python3.5 is irrelevant on a focal+ charm.
63commands = /bin/true
64
65[testenv:py36]
66basepython = python3.6
67deps = -r{toxinidir}/requirements.txt
68 -r{toxinidir}/test-requirements.txt
69
70[testenv:py37]
71basepython = python3.7
72deps = -r{toxinidir}/requirements.txt
73 -r{toxinidir}/test-requirements.txt
74
75[testenv:py38]
76basepython = python3.8
77deps = -r{toxinidir}/requirements.txt
78 -r{toxinidir}/test-requirements.txt
79
80[testenv:py39]
81basepython = python3.9
82deps = -r{toxinidir}/requirements.txt
83 -r{toxinidir}/test-requirements.txt
84
85[testenv:py3]
86basepython = python3
87deps = -r{toxinidir}/requirements.txt
88 -r{toxinidir}/test-requirements.txt
89
Biser Milanov3fc57d72022-09-07 13:04:47 +030090[testenv:isort]
91basepython = python3
92deps = isort
93commands =
94 isort {[defs]pyfiles}
95
Peter Pentchev469dfea2022-06-27 12:48:18 +030096[testenv:pep8]
97basepython = python3
98deps = -r{toxinidir}/requirements.txt
99 -r{toxinidir}/test-requirements.txt
100commands = flake8 {posargs} src unit_tests tests
101
Biser Milanov3fc57d72022-09-07 13:04:47 +0300102[testenv:lint]
103basepython = python3
104deps =
105 pylint
106 -r{toxinidir}/requirements.txt
107 -r{toxinidir}/build-requirements.txt
108 -r{toxinidir}/test-requirements.txt
109commands =
110 pylint {[defs]pyfiles}
111
Peter Pentchev469dfea2022-06-27 12:48:18 +0300112[testenv:cover]
113# Technique based heavily upon
114# https://github.com/openstack/nova/blob/master/tox.ini
115basepython = python3
116deps = -r{toxinidir}/requirements.txt
117 -r{toxinidir}/test-requirements.txt
118setenv =
119 {[testenv]setenv}
120 PYTHON=coverage run
121commands =
122 coverage erase
123 stestr run --slowest {posargs}
124 coverage combine
125 coverage html -d cover
126 coverage xml -o cover/coverage.xml
127 coverage report
128
129[coverage:run]
130branch = True
131concurrency = multiprocessing
132parallel = True
133source =
134 .
135omit =
136 .tox/*
137 */charmhelpers/*
138 unit_tests/*
139
140[testenv:venv]
141basepython = python3
142commands = {posargs}
143
144[testenv:build]
145basepython = python3
146deps = -r{toxinidir}/build-requirements.txt
147# NOTE(lourot): charmcraft 1.0.0 used to generate
148# cinder-StorPool.charm, which is the behaviour expected
149# by OSCI. However charmcraft 1.2.1 now generates
150# cinder-StorPool_ubuntu-20.04-amd64.charm instead.
151# In order to keep the old behaviour we rename the file at the end.
152commands =
153 charmcraft clean
Biser Milanov75fadfa2022-08-17 16:50:11 +0300154 charmcraft -v pack
Peter Pentchev469dfea2022-06-27 12:48:18 +0300155 {toxinidir}/rename.sh
156
157[testenv:func-noop]
158basepython = python3
Biser Milanovbffa6872022-09-01 11:36:06 +0300159passenv = {[defs]func_env_vars}
Peter Pentchev469dfea2022-06-27 12:48:18 +0300160commands =
161 functest-run-suite --help
162
163[testenv:func]
164basepython = python3
Biser Milanovbffa6872022-09-01 11:36:06 +0300165passenv = {[defs]func_env_vars}
Peter Pentchev469dfea2022-06-27 12:48:18 +0300166commands =
167 functest-run-suite --keep-model
168
169[testenv:func-smoke]
170basepython = python3
Biser Milanovbffa6872022-09-01 11:36:06 +0300171passenv = {[defs]func_env_vars}
Peter Pentchev469dfea2022-06-27 12:48:18 +0300172commands =
173 functest-run-suite --keep-model --smoke
174
175[testenv:func-dev]
176basepython = python3
Biser Milanovbffa6872022-09-01 11:36:06 +0300177passenv = {[defs]func_env_vars}
Peter Pentchev469dfea2022-06-27 12:48:18 +0300178commands =
179 functest-run-suite --keep-model --dev
180
181[testenv:func-target]
182basepython = python3
Biser Milanovbffa6872022-09-01 11:36:06 +0300183passenv = {[defs]func_env_vars}
Peter Pentchev469dfea2022-06-27 12:48:18 +0300184commands =
185 functest-run-suite --keep-model --bundle {posargs}
186
Biser Milanov4022e5a2022-12-12 17:22:29 +0200187[testenv:func-target-discard-model]
188basepython = python3
189passenv = {[defs]func_env_vars}
190commands =
191 functest-run-suite --bundle {posargs}
192
Biser Milanov53644f62022-08-03 16:08:59 +0300193[testenv:black-reformat]
194deps =
195 black >= 22, < 23
196commands =
197 black {[defs]pyfiles}
198
199[testenv:black]
200deps =
201 black >= 22, < 23
202commands =
203 black --check {[defs]pyfiles}