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 | |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 42 | [testenv] |
| 43 | setenv = VIRTUAL_ENV={envdir} |
| 44 | PYTHONHASHSEED=0 |
| 45 | CHARM_DIR={envdir} |
| 46 | install_command = |
| 47 | pip install {opts} {packages} |
| 48 | commands = stestr run --slowest {posargs} |
| 49 | allowlist_externals = |
| 50 | git |
| 51 | bash |
| 52 | charmcraft |
| 53 | rename.sh |
| 54 | passenv = HOME TERM CS_* OS_* TEST_* |
| 55 | deps = -r{toxinidir}/test-requirements.txt |
| 56 | |
| 57 | [testenv:py35] |
| 58 | basepython = python3.5 |
| 59 | # python3.5 is irrelevant on a focal+ charm. |
| 60 | commands = /bin/true |
| 61 | |
| 62 | [testenv:py36] |
| 63 | basepython = python3.6 |
| 64 | deps = -r{toxinidir}/requirements.txt |
| 65 | -r{toxinidir}/test-requirements.txt |
| 66 | |
| 67 | [testenv:py37] |
| 68 | basepython = python3.7 |
| 69 | deps = -r{toxinidir}/requirements.txt |
| 70 | -r{toxinidir}/test-requirements.txt |
| 71 | |
| 72 | [testenv:py38] |
| 73 | basepython = python3.8 |
| 74 | deps = -r{toxinidir}/requirements.txt |
| 75 | -r{toxinidir}/test-requirements.txt |
| 76 | |
| 77 | [testenv:py39] |
| 78 | basepython = python3.9 |
| 79 | deps = -r{toxinidir}/requirements.txt |
| 80 | -r{toxinidir}/test-requirements.txt |
| 81 | |
| 82 | [testenv:py3] |
| 83 | basepython = python3 |
| 84 | deps = -r{toxinidir}/requirements.txt |
| 85 | -r{toxinidir}/test-requirements.txt |
| 86 | |
| 87 | [testenv:pep8] |
| 88 | basepython = python3 |
| 89 | deps = -r{toxinidir}/requirements.txt |
| 90 | -r{toxinidir}/test-requirements.txt |
| 91 | commands = 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 |
| 96 | basepython = python3 |
| 97 | deps = -r{toxinidir}/requirements.txt |
| 98 | -r{toxinidir}/test-requirements.txt |
| 99 | setenv = |
| 100 | {[testenv]setenv} |
| 101 | PYTHON=coverage run |
| 102 | commands = |
| 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] |
| 111 | branch = True |
| 112 | concurrency = multiprocessing |
| 113 | parallel = True |
| 114 | source = |
| 115 | . |
| 116 | omit = |
| 117 | .tox/* |
| 118 | */charmhelpers/* |
| 119 | unit_tests/* |
| 120 | |
| 121 | [testenv:venv] |
| 122 | basepython = python3 |
| 123 | commands = {posargs} |
| 124 | |
| 125 | [testenv:build] |
| 126 | basepython = python3 |
| 127 | deps = -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. |
| 133 | commands = |
| 134 | charmcraft clean |
Biser Milanov | 75fadfa | 2022-08-17 16:50:11 +0300 | [diff] [blame] | 135 | charmcraft -v pack |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 136 | {toxinidir}/rename.sh |
| 137 | |
| 138 | [testenv:func-noop] |
| 139 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame^] | 140 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 141 | commands = |
| 142 | functest-run-suite --help |
| 143 | |
| 144 | [testenv:func] |
| 145 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame^] | 146 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 147 | commands = |
| 148 | functest-run-suite --keep-model |
| 149 | |
| 150 | [testenv:func-smoke] |
| 151 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame^] | 152 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 153 | commands = |
| 154 | functest-run-suite --keep-model --smoke |
| 155 | |
| 156 | [testenv:func-dev] |
| 157 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame^] | 158 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 159 | commands = |
| 160 | functest-run-suite --keep-model --dev |
| 161 | |
| 162 | [testenv:func-target] |
| 163 | basepython = python3 |
Biser Milanov | bffa687 | 2022-09-01 11:36:06 +0300 | [diff] [blame^] | 164 | passenv = {[defs]func_env_vars} |
Peter Pentchev | 469dfea | 2022-06-27 12:48:18 +0300 | [diff] [blame] | 165 | commands = |
| 166 | functest-run-suite --keep-model --bundle {posargs} |
| 167 | |
Biser Milanov | 53644f6 | 2022-08-03 16:08:59 +0300 | [diff] [blame] | 168 | [testenv:black-reformat] |
| 169 | deps = |
| 170 | black >= 22, < 23 |
| 171 | commands = |
| 172 | black {[defs]pyfiles} |
| 173 | |
| 174 | [testenv:black] |
| 175 | deps = |
| 176 | black >= 22, < 23 |
| 177 | commands = |
| 178 | black --check {[defs]pyfiles} |