| 1 | [tox] |
| 2 | minversion = 3.21 |
| 3 | # relies on the correct version of Python installed |
| 4 | envlist = ruff,tests,mypy,ty |
| 5 | # https://github.com/tox-dev/tox/issues/20#issuecomment-247788333 |
| 6 | # hack to prevent .tox from crapping to the project directory |
| 7 | toxworkdir = {env:TOXWORKDIR_BASE:}{toxinidir}/.tox |
| 8 | |
| 9 | [testenv] |
| 10 | # TODO how to get package name from setuptools? |
| 11 | package_name = "orgparse" |
| 12 | pass_env = |
| 13 | # useful for tests to know they are running under ci |
| 14 | CI |
| 15 | CI_* |
| 16 | # respect user's cache dirs to prevent tox from crapping into project dir |
| 17 | PYTHONPYCACHEPREFIX |
| 18 | MYPY_CACHE_DIR |
| 19 | RUFF_CACHE_DIR |
| 20 | |
| 21 | set_env = |
| 22 | # do not add current working directory to pythonpath |
| 23 | # generally this is more robust and safer, prevents weird issues later on |
| 24 | PYTHONSAFEPATH=1 |
| 25 | |
| 26 | # default is 'editable', in which tox builds wheel first for some reason? not sure if makes much sense |
| 27 | package = uv-editable |
| 28 | |
| 29 | |
| 30 | [testenv:ruff] |
| 31 | skip_install = true |
| 32 | dependency_groups = testing |
| 33 | commands = |
| 34 | {envpython} -m ruff check \ |
| 35 | {posargs} |
| 36 | |
| 37 | |
| 38 | [testenv:tests] |
| 39 | dependency_groups = testing |
| 40 | commands = |
| 41 | # posargs allow test filtering, e.g. tox ... -- -k test_name |
| 42 | {envpython} -m pytest \ |
| 43 | --pyargs {[testenv]package_name} \ |
| 44 | {posargs} |
| 45 | |
| 46 | |
| 47 | [testenv:mypy] |
| 48 | dependency_groups = testing |
| 49 | commands = |
| 50 | {envpython} -m mypy --no-install-types \ |
| 51 | -p {[testenv]package_name} \ |
| 52 | --txt-report .coverage.mypy \ |
| 53 | --html-report .coverage.mypy \ |
| 54 | # this is for github actions to upload to codecov.io |
| 55 | # sadly xml coverage crashes on windows... so we need to disable it |
| 56 | {env:CI_MYPY_COVERAGE} \ |
| 57 | {posargs} |
| 58 | |
| 59 | |
| 60 | [testenv:ty] |
| 61 | dependency_groups = testing |
| 62 | extras = optional |
| 63 | deps = # any other dependencies (if needed) |
| 64 | commands = |
| 65 | {envpython} -m ty \ |
| 66 | check \ |
| 67 | {posargs} |