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