###############################################################################
# 📦 tox.ini - multi-interpreter test matrix powered by uv #
###############################################################################
#
# ➡ Why tox-uv?
# - one-shot lock-file-free dependency resolution (⚡ fast)
# - identical logic on macOS / Linux / Windows
# - ultra-small virtualenvs under ~/.cache/uv/venv
#
# ➡ Quickstart
# uv pip install tox tox-uv # install once
# tox -p auto # run whole matrix
#
# ➡ Environments
# py311 / py312 / py313 → doctest + unit tests (pytest)
#
###############################################################################
#############################
# Core tox configuration
#############################
[tox]
requires = tox>=4, tox-uv # 🔗 plugin discovery happens through this
envlist = py311, py312, py313
skip_missing_interpreters = true # dev machines that miss 3.13-dev
# uv configuration for Python installation
uv_python_preference = only-managed # Only use uv-managed Python versions
#########################################
# GitHub-Actions / Azure DevOps mapping
#########################################
[gh-actions]
python =
3.11: py311
3.12: py312
3.13: py313
#####################################################################
# 🔬 Default test environment #
# Every pyXY uses the same definition; only the interpreter differs. #
#####################################################################
[testenv] # <-- inherited by py311 / py312 / py313
runner = uv-venv-runner # tox-uv: create venv via 'uv venv'
package = uv-editable # install our package *editable* with 'uv pip'
extras = dev # pulls in pytest, coverage, ruff, ...
description = Run doctest and unit tests with {basepython}
commands =
python -m pytest --doctest-modules mcpgateway/ --tb=short -q
python -m pytest --maxfail=0 --disable-warnings -v --ignore=tests/fuzz --ignore=tests/playwright
# Python 3.13 specific environment - exclude packages that don't support 3.13 yet
[testenv:py313]
runner = uv-venv-runner
package = skip
deps =
# Install the package manually without dev extras
-e .
# Install core dependencies without problematic packages
aiohttp>=3.12.15
alembic>=1.16.5
argon2-cffi>=25.1.0
copier>=9.10.1
cryptography>=45.0.7
fastapi>=0.116.1
filelock>=3.19.1
gunicorn>=23.0.0
httpx>=0.28.1
httpx[http2]>=0.28.1
jinja2>=3.1.6
jq>=1.10.0
jsonpath-ng>=1.7.0
jsonschema>=4.25.1
mcp>=1.13.1
oauthlib>=3.3.1
parse>=1.20.2
psutil>=7.0.0
pydantic>=2.11.7
pydantic[email]>=2.11.7
pydantic-settings>=2.10.1
pyjwt>=2.10.1
python-json-logger>=3.3.0
PyYAML>=6.0.2
requests-oauthlib>=2.0.0
sqlalchemy>=2.0.43
sse-starlette>=3.0.2
starlette>=0.47.3
typer>=0.17.4
uvicorn>=0.35.0
zeroconf>=0.147.2
# Test dependencies
pytest>=8.4.2
pytest-asyncio>=1.1.0
pytest-cov>=6.2.1
pytest-env>=1.1.5
coverage>=7.10.6
chuk-mcp-runtime>=0.6.5
# Skip pytype, libcst and other packages that don't support Python 3.13 yet
description = Run doctest and unit tests with Python 3.13 (excluding unsupported packages)
commands =
python -m pytest --doctest-modules mcpgateway/ --tb=short -q
python -m pytest --maxfail=0 --disable-warnings -v --ignore=tests/fuzz --ignore=tests/playwright
passenv =
DATABASE_URL
MCPGATEWAY_* # <-- commonly used by this repo's tests
AUTH_* #
CACHE_* #
setenv =
PYTHONWARNINGS = ignore::DeprecationWarning
##########################
# 🧹 Code style & lint
##########################
[testenv:lint]
runner = uv-venv-runner
skip_install = true # linting doesn't need our package importable
extras = dev
description = Static-analysis (ruff + black -check + isort -check + bandit)
commands =
ruff check .
black --check .
isort --check-only .
bandit -r mcpgateway -n 5
pre-commit run --all-files --show-diff-on-failure
###################################
# 🔍 Strict static type checking
###################################
[testenv:type]
runner = uv-venv-runner
skip_install = true
extras = dev
description = Mypy strict type-checking
commands =
mypy mcpgateway tests --install-types --non-interactive
################################
# 📦 Build sdist + universal wheel
################################
[testenv:pkg]
runner = uv-venv-runner
skip_install = true
deps = build # minimal requirement for PEP 517 build
description = Build wheel + sdist via uv
commands =
python3 -m build --sdist --wheel --outdir {toxworkdir}/dist
###############################################################################
# ☑︎ Advanced uv knobs (optional - uncomment if you need them)
###############################################################################
# [testenv]
# uv_seed = true # ⤷ inject pip/setuptools/wheel (legacy builds)
# uv_resolution = lowest # ⤷ lowest, lowest-direct, highest (default)
# system_site_packages = false # ⤷ give env access to global site-pkgs
#
# [testenv:lock-example]
# runner = uv-venv-lock-runner # use uv.lock + uv sync
# extras = dev # install [dev] extras listed in uv.lock
###############################################################################