Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 1 | # Operator charm (with zaza): tox.ini |
| 2 | |
| 3 | [tox] |
| 4 | envlist = pep8,py3 |
| 5 | skipsdist = True |
| 6 | # NOTE: Avoid build/test env pollution by not enabling sitepackages. |
| 7 | sitepackages = False |
| 8 | # NOTE: Avoid false positives by not skipping missing interpreters. |
| 9 | skip_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`. |
| 21 | requires = pip < 20.3 |
| 22 | virtualenv < 20.0 |
| 23 | setuptools < 50.0.0 |
Peter Pentchev | 4c57710 | 2022-12-08 17:15:51 +0200 | [diff] [blame] | 24 | tox < 4 |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 25 | # NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci |
| 26 | minversion = 3.2.0 |
| 27 | |
Biser Milanov | 53644f6 | 2022-08-03 16:08:59 +0300 | [diff] [blame] | 28 | [defs] |
| 29 | pyfiles = |
| 30 | src |
| 31 | tests |
| 32 | unit_tests |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame] | 33 | func_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 Milanov | 53644f6 | 2022-08-03 16:08:59 +0300 | [diff] [blame] | 41 | |
Biser Milanov | 3fc57d7 | 2022-09-07 13:04:47 +0300 | [diff] [blame] | 42 | [tools:isort] |
| 43 | profile = "black" |
| 44 | |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 45 | [testenv] |
| 46 | setenv = VIRTUAL_ENV={envdir} |
| 47 | PYTHONHASHSEED=0 |
| 48 | CHARM_DIR={envdir} |
| 49 | install_command = |
| 50 | pip install {opts} {packages} |
| 51 | commands = stestr run --slowest {posargs} |
| 52 | allowlist_externals = |
| 53 | git |
| 54 | bash |
| 55 | charmcraft |
| 56 | rename.sh |
| 57 | passenv = HOME TERM CS_* OS_* TEST_* |
| 58 | deps = -r{toxinidir}/test-requirements.txt |
| 59 | |
| 60 | [testenv:py35] |
| 61 | basepython = python3.5 |
| 62 | # python3.5 is irrelevant on a focal+ charm. |
| 63 | commands = /bin/true |
| 64 | |
| 65 | [testenv:py36] |
| 66 | basepython = python3.6 |
| 67 | deps = -r{toxinidir}/requirements.txt |
| 68 | -r{toxinidir}/test-requirements.txt |
| 69 | |
| 70 | [testenv:py37] |
| 71 | basepython = python3.7 |
| 72 | deps = -r{toxinidir}/requirements.txt |
| 73 | -r{toxinidir}/test-requirements.txt |
| 74 | |
| 75 | [testenv:py38] |
| 76 | basepython = python3.8 |
| 77 | deps = -r{toxinidir}/requirements.txt |
| 78 | -r{toxinidir}/test-requirements.txt |
| 79 | |
| 80 | [testenv:py39] |
| 81 | basepython = python3.9 |
| 82 | deps = -r{toxinidir}/requirements.txt |
| 83 | -r{toxinidir}/test-requirements.txt |
| 84 | |
| 85 | [testenv:py3] |
| 86 | basepython = python3 |
| 87 | deps = -r{toxinidir}/requirements.txt |
| 88 | -r{toxinidir}/test-requirements.txt |
| 89 | |
Biser Milanov | 3fc57d7 | 2022-09-07 13:04:47 +0300 | [diff] [blame] | 90 | [testenv:isort] |
| 91 | basepython = python3 |
| 92 | deps = isort |
| 93 | commands = |
| 94 | isort {[defs]pyfiles} |
| 95 | |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 96 | [testenv:pep8] |
| 97 | basepython = python3 |
| 98 | deps = -r{toxinidir}/requirements.txt |
| 99 | -r{toxinidir}/test-requirements.txt |
| 100 | commands = flake8 {posargs} src unit_tests tests |
| 101 | |
Biser Milanov | 3fc57d7 | 2022-09-07 13:04:47 +0300 | [diff] [blame] | 102 | [testenv:lint] |
| 103 | basepython = python3 |
| 104 | deps = |
| 105 | pylint |
| 106 | -r{toxinidir}/requirements.txt |
| 107 | -r{toxinidir}/build-requirements.txt |
| 108 | -r{toxinidir}/test-requirements.txt |
| 109 | commands = |
| 110 | pylint {[defs]pyfiles} |
| 111 | |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 112 | [testenv:cover] |
| 113 | # Technique based heavily upon |
| 114 | # https://github.com/openstack/nova/blob/master/tox.ini |
| 115 | basepython = python3 |
| 116 | deps = -r{toxinidir}/requirements.txt |
| 117 | -r{toxinidir}/test-requirements.txt |
| 118 | setenv = |
| 119 | {[testenv]setenv} |
| 120 | PYTHON=coverage run |
| 121 | commands = |
| 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] |
| 130 | branch = True |
| 131 | concurrency = multiprocessing |
| 132 | parallel = True |
| 133 | source = |
| 134 | . |
| 135 | omit = |
| 136 | .tox/* |
| 137 | */charmhelpers/* |
| 138 | unit_tests/* |
| 139 | |
| 140 | [testenv:venv] |
| 141 | basepython = python3 |
| 142 | commands = {posargs} |
| 143 | |
| 144 | [testenv:build] |
| 145 | basepython = python3 |
| 146 | deps = -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. |
| 152 | commands = |
| 153 | charmcraft clean |
Biser Milanov | 75fadfa | 2022-08-17 16:50:11 +0300 | [diff] [blame] | 154 | charmcraft -v pack |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 155 | {toxinidir}/rename.sh |
| 156 | |
| 157 | [testenv:func-noop] |
| 158 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame] | 159 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 160 | commands = |
| 161 | functest-run-suite --help |
| 162 | |
| 163 | [testenv:func] |
| 164 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame] | 165 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 166 | commands = |
| 167 | functest-run-suite --keep-model |
| 168 | |
| 169 | [testenv:func-smoke] |
| 170 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame] | 171 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 172 | commands = |
| 173 | functest-run-suite --keep-model --smoke |
| 174 | |
| 175 | [testenv:func-dev] |
| 176 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame] | 177 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 178 | commands = |
| 179 | functest-run-suite --keep-model --dev |
| 180 | |
| 181 | [testenv:func-target] |
| 182 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame] | 183 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 184 | commands = |
| 185 | functest-run-suite --keep-model --bundle {posargs} |
| 186 | |
Biser Milanov | 4022e5a | 2022-12-12 17:22:29 +0200 | [diff] [blame] | 187 | [testenv:func-target-discard-model] |
| 188 | basepython = python3 |
| 189 | passenv = {[defs]func_env_vars} |
| 190 | commands = |
| 191 | functest-run-suite --bundle {posargs} |
| 192 | |
Biser Milanov | 53644f6 | 2022-08-03 16:08:59 +0300 | [diff] [blame] | 193 | [testenv:black-reformat] |
| 194 | deps = |
| 195 | black >= 22, < 23 |
| 196 | commands = |
| 197 | black {[defs]pyfiles} |
| 198 | |
| 199 | [testenv:black] |
| 200 | deps = |
| 201 | black >= 22, < 23 |
| 202 | commands = |
| 203 | black --check {[defs]pyfiles} |