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