###############################################################################
# π¦ 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
# py310 / py311 / py312 / py313 β full test-suite (pytest)
# lint β Ruff + Black + isort + etc.
# type β mypy strict type-checking
# pkg β build sdist + wheel with uv
#
###############################################################################
#############################
# Core tox configuration
#############################
[tox]
requires = tox>=4 # π plugin discovery happens through this
envlist = py310, py311, py312, py313, lint, type, pkg
skip_missing_interpreters = true # dev machines that miss 3.13-dev
#########################################
# GitHub-Actions / Azure DevOps mapping
#########################################
[gh-actions]
python =
3.10: py310
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 py310 / py311 / ...
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 pytest against {basepython}
commands =
pytest -q {posargs}
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
###############################################################################