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 | |
| 28 | [testenv] |
| 29 | setenv = VIRTUAL_ENV={envdir} |
| 30 | PYTHONHASHSEED=0 |
| 31 | CHARM_DIR={envdir} |
| 32 | install_command = |
| 33 | pip install {opts} {packages} |
| 34 | commands = stestr run --slowest {posargs} |
| 35 | allowlist_externals = |
| 36 | git |
| 37 | bash |
| 38 | charmcraft |
| 39 | rename.sh |
| 40 | passenv = HOME TERM CS_* OS_* TEST_* |
| 41 | deps = -r{toxinidir}/test-requirements.txt |
| 42 | |
| 43 | [testenv:py35] |
| 44 | basepython = python3.5 |
| 45 | # python3.5 is irrelevant on a focal+ charm. |
| 46 | commands = /bin/true |
| 47 | |
| 48 | [testenv:py36] |
| 49 | basepython = python3.6 |
| 50 | deps = -r{toxinidir}/requirements.txt |
| 51 | -r{toxinidir}/test-requirements.txt |
| 52 | |
| 53 | [testenv:py37] |
| 54 | basepython = python3.7 |
| 55 | deps = -r{toxinidir}/requirements.txt |
| 56 | -r{toxinidir}/test-requirements.txt |
| 57 | |
| 58 | [testenv:py38] |
| 59 | basepython = python3.8 |
| 60 | deps = -r{toxinidir}/requirements.txt |
| 61 | -r{toxinidir}/test-requirements.txt |
| 62 | |
| 63 | [testenv:py39] |
| 64 | basepython = python3.9 |
| 65 | deps = -r{toxinidir}/requirements.txt |
| 66 | -r{toxinidir}/test-requirements.txt |
| 67 | |
| 68 | [testenv:py3] |
| 69 | basepython = python3 |
| 70 | deps = -r{toxinidir}/requirements.txt |
| 71 | -r{toxinidir}/test-requirements.txt |
| 72 | |
| 73 | [testenv:pep8] |
| 74 | basepython = python3 |
| 75 | deps = -r{toxinidir}/requirements.txt |
| 76 | -r{toxinidir}/test-requirements.txt |
| 77 | commands = 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 |
| 82 | basepython = python3 |
| 83 | deps = -r{toxinidir}/requirements.txt |
| 84 | -r{toxinidir}/test-requirements.txt |
| 85 | setenv = |
| 86 | {[testenv]setenv} |
| 87 | PYTHON=coverage run |
| 88 | commands = |
| 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] |
| 97 | branch = True |
| 98 | concurrency = multiprocessing |
| 99 | parallel = True |
| 100 | source = |
| 101 | . |
| 102 | omit = |
| 103 | .tox/* |
| 104 | */charmhelpers/* |
| 105 | unit_tests/* |
| 106 | |
| 107 | [testenv:venv] |
| 108 | basepython = python3 |
| 109 | commands = {posargs} |
| 110 | |
| 111 | [testenv:build] |
| 112 | basepython = python3 |
| 113 | deps = -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. |
| 119 | commands = |
| 120 | charmcraft clean |
| 121 | charmcraft -v build |
| 122 | {toxinidir}/rename.sh |
| 123 | |
| 124 | [testenv:func-noop] |
| 125 | basepython = python3 |
| 126 | commands = |
| 127 | functest-run-suite --help |
| 128 | |
| 129 | [testenv:func] |
| 130 | basepython = python3 |
| 131 | commands = |
| 132 | functest-run-suite --keep-model |
| 133 | |
| 134 | [testenv:func-smoke] |
| 135 | basepython = python3 |
| 136 | commands = |
| 137 | functest-run-suite --keep-model --smoke |
| 138 | |
| 139 | [testenv:func-dev] |
| 140 | basepython = python3 |
| 141 | commands = |
| 142 | functest-run-suite --keep-model --dev |
| 143 | |
| 144 | [testenv:func-target] |
| 145 | basepython = python3 |
| 146 | commands = |
| 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. |
| 151 | ignore = E402,E226,W503,W504,E902 |