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