|
| 1 | +############################################################################### |
| 2 | +# 📦 tox.ini — multi-interpreter test matrix powered by uv # |
| 3 | +############################################################################### |
| 4 | +# |
| 5 | +# ➡ Why tox-uv? |
| 6 | +# • one-shot lock-file-free dependency resolution (⚡ fast) |
| 7 | +# • identical logic on macOS / Linux / Windows |
| 8 | +# • ultra-small virtualenvs under ~/.cache/uv/venv |
| 9 | +# |
| 10 | +# ➡ Quickstart |
| 11 | +# uv pip install tox tox-uv # install once |
| 12 | +# tox -p auto # run whole matrix |
| 13 | +# |
| 14 | +# ➡ Environments |
| 15 | +# py310 / py311 / py312 / py313 → full test-suite (pytest) |
| 16 | +# lint → Ruff + Black + isort + etc. |
| 17 | +# type → mypy strict type-checking |
| 18 | +# pkg → build sdist + wheel with uv |
| 19 | +# |
| 20 | +############################################################################### |
| 21 | + |
| 22 | +############################# |
| 23 | +# Core tox configuration |
| 24 | +############################# |
| 25 | +[tox] |
| 26 | +requires = tox>=4 # 🔗 plugin discovery happens through this |
| 27 | +envlist = py310, py311, py312, py313, lint, type, pkg |
| 28 | +skip_missing_interpreters = true # dev machines that miss 3.13-dev |
| 29 | + |
| 30 | +######################################### |
| 31 | +# GitHub-Actions / Azure DevOps mapping |
| 32 | +######################################### |
| 33 | +[gh-actions] |
| 34 | +python = |
| 35 | + 3.10: py310 |
| 36 | + 3.11: py311 |
| 37 | + 3.12: py312 |
| 38 | + 3.13: py313 |
| 39 | + |
| 40 | +##################################################################### |
| 41 | +# 🔬 Default test environment # |
| 42 | +# Every pyXY uses the same definition; only the interpreter differs. # |
| 43 | +##################################################################### |
| 44 | +[testenv] # <-- inherited by py310 / py311 / … |
| 45 | +runner = uv-venv-runner # tox-uv: create venv via 'uv venv' |
| 46 | +package = uv-editable # install our package *editable* with 'uv pip' |
| 47 | +extras = dev # pulls in pytest, coverage, ruff, … |
| 48 | +description = Run pytest against {basepython} |
| 49 | +commands = |
| 50 | + pytest -q {posargs} |
| 51 | + |
| 52 | +passenv = |
| 53 | + DATABASE_URL |
| 54 | + MCPGATEWAY_* # <-- commonly used by this repo's tests |
| 55 | + AUTH_* # |
| 56 | + CACHE_* # |
| 57 | +setenv = |
| 58 | + PYTHONWARNINGS = ignore::DeprecationWarning |
| 59 | + |
| 60 | +########################## |
| 61 | +# 🧹 Code style & lint |
| 62 | +########################## |
| 63 | +[testenv:lint] |
| 64 | +runner = uv-venv-runner |
| 65 | +skip_install = true # linting doesn't need our package importable |
| 66 | +extras = dev |
| 67 | +description = Static-analysis (ruff + black –check + isort –check + bandit) |
| 68 | +commands = |
| 69 | + ruff check . |
| 70 | + black --check . |
| 71 | + isort --check-only . |
| 72 | + bandit -r mcpgateway -n 5 |
| 73 | + pre-commit run --all-files --show-diff-on-failure |
| 74 | + |
| 75 | +################################### |
| 76 | +# 🔍 Strict static type checking |
| 77 | +################################### |
| 78 | +[testenv:type] |
| 79 | +runner = uv-venv-runner |
| 80 | +skip_install = true |
| 81 | +extras = dev |
| 82 | +description = Mypy strict type-checking |
| 83 | +commands = |
| 84 | + mypy mcpgateway tests --install-types --non-interactive |
| 85 | + |
| 86 | +################################ |
| 87 | +# 📦 Build sdist + universal wheel |
| 88 | +################################ |
| 89 | +[testenv:pkg] |
| 90 | +runner = uv-venv-runner |
| 91 | +skip_install = true |
| 92 | +deps = build # minimal requirement for PEP 517 build |
| 93 | +description = Build wheel + sdist via uv |
| 94 | +commands = |
| 95 | + python -m build --sdist --wheel --outdir {toxworkdir}/dist |
| 96 | + |
| 97 | +############################################################################### |
| 98 | +# ☑︎ Advanced uv knobs (optional — uncomment if you need them) |
| 99 | +############################################################################### |
| 100 | +# [testenv] |
| 101 | +# uv_seed = true # ⤷ inject pip/setuptools/wheel (legacy builds) |
| 102 | +# uv_resolution = lowest # ⤷ lowest, lowest-direct, highest (default) |
| 103 | +# system_site_packages = false # ⤷ give env access to global site-pkgs |
| 104 | +# |
| 105 | +# [testenv:lock-example] |
| 106 | +# runner = uv-venv-lock-runner # use uv.lock + uv sync |
| 107 | +# extras = dev # install [dev] extras listed in uv.lock |
| 108 | +############################################################################### |
0 commit comments