blob: 0ee1b02900d51da13c85fa015f77ebd341de2850 [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
33
Peter Pentchev469dfea2022-06-27 12:48:18 +030034[testenv]
35setenv = VIRTUAL_ENV={envdir}
36 PYTHONHASHSEED=0
37 CHARM_DIR={envdir}
38install_command =
39 pip install {opts} {packages}
40commands = stestr run --slowest {posargs}
41allowlist_externals =
42 git
43 bash
44 charmcraft
45 rename.sh
46passenv = HOME TERM CS_* OS_* TEST_*
47deps = -r{toxinidir}/test-requirements.txt
48
49[testenv:py35]
50basepython = python3.5
51# python3.5 is irrelevant on a focal+ charm.
52commands = /bin/true
53
54[testenv:py36]
55basepython = python3.6
56deps = -r{toxinidir}/requirements.txt
57 -r{toxinidir}/test-requirements.txt
58
59[testenv:py37]
60basepython = python3.7
61deps = -r{toxinidir}/requirements.txt
62 -r{toxinidir}/test-requirements.txt
63
64[testenv:py38]
65basepython = python3.8
66deps = -r{toxinidir}/requirements.txt
67 -r{toxinidir}/test-requirements.txt
68
69[testenv:py39]
70basepython = python3.9
71deps = -r{toxinidir}/requirements.txt
72 -r{toxinidir}/test-requirements.txt
73
74[testenv:py3]
75basepython = python3
76deps = -r{toxinidir}/requirements.txt
77 -r{toxinidir}/test-requirements.txt
78
79[testenv:pep8]
80basepython = python3
81deps = -r{toxinidir}/requirements.txt
82 -r{toxinidir}/test-requirements.txt
83commands = flake8 {posargs} src unit_tests tests
84
85[testenv:cover]
86# Technique based heavily upon
87# https://github.com/openstack/nova/blob/master/tox.ini
88basepython = python3
89deps = -r{toxinidir}/requirements.txt
90 -r{toxinidir}/test-requirements.txt
91setenv =
92 {[testenv]setenv}
93 PYTHON=coverage run
94commands =
95 coverage erase
96 stestr run --slowest {posargs}
97 coverage combine
98 coverage html -d cover
99 coverage xml -o cover/coverage.xml
100 coverage report
101
102[coverage:run]
103branch = True
104concurrency = multiprocessing
105parallel = True
106source =
107 .
108omit =
109 .tox/*
110 */charmhelpers/*
111 unit_tests/*
112
113[testenv:venv]
114basepython = python3
115commands = {posargs}
116
117[testenv:build]
118basepython = python3
119deps = -r{toxinidir}/build-requirements.txt
120# NOTE(lourot): charmcraft 1.0.0 used to generate
121# cinder-StorPool.charm, which is the behaviour expected
122# by OSCI. However charmcraft 1.2.1 now generates
123# cinder-StorPool_ubuntu-20.04-amd64.charm instead.
124# In order to keep the old behaviour we rename the file at the end.
125commands =
126 charmcraft clean
127 charmcraft -v build
128 {toxinidir}/rename.sh
129
130[testenv:func-noop]
131basepython = python3
132commands =
133 functest-run-suite --help
134
135[testenv:func]
136basepython = python3
137commands =
138 functest-run-suite --keep-model
139
140[testenv:func-smoke]
141basepython = python3
142commands =
143 functest-run-suite --keep-model --smoke
144
145[testenv:func-dev]
146basepython = python3
147commands =
148 functest-run-suite --keep-model --dev
149
150[testenv:func-target]
151basepython = python3
152commands =
153 functest-run-suite --keep-model --bundle {posargs}
154
Biser Milanov53644f62022-08-03 16:08:59 +0300155[testenv:black-reformat]
156deps =
157 black >= 22, < 23
158commands =
159 black {[defs]pyfiles}
160
161[testenv:black]
162deps =
163 black >= 22, < 23
164commands =
165 black --check {[defs]pyfiles}