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