Skip to content

Commit dbfa5c1

Browse files
authored
Merge pull request #142 from IBM/tox
Added tox
2 parents 934a292 + c88d56f commit dbfa5c1

File tree

5 files changed

+1125
-985
lines changed

5 files changed

+1125
-985
lines changed

.github/workflows/tox.yml.inactive

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
tox:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python: ["3.10", "3.11", "3.12", "3.13-dev"]
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
# ① Install the runner interpreter for this job
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: ${{ matrix.python }}
18+
19+
# ② Install tox + plugin with uv
20+
- name: Install tox (uv)
21+
run: |
22+
curl -Ls https://astral.sh/uv/install.sh | sh # or `pipx install uv`
23+
uv pip install tox tox-uv
24+
25+
# ③ Run the whole envlist (pyXY env will match the current job interpreter)
26+
- name: Run tox matrix
27+
run: tox -p auto

Makefile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,9 @@ pstats: ## 📊 Static call-graph image
430430
spellcheck-sort: .spellcheck-en.txt ## 🔤 Sort spell-list
431431
sort -d -f -o $< $<
432432

433-
tox: ## 🧪 Multi-Python tox matrix
434-
@echo "🧪 Running tox …"
435-
uv pip install tox-travis tox-pdm
436-
pdm add -G dev
437-
pdm python install 3.11 3.12
438-
python3 -m tox -p 2
433+
tox: ## 🧪 Multi-Python tox matrix (uv)
434+
@echo "🧪 Running tox with uv …"
435+
python -m tox -p auto $(TOXARGS)
439436

440437
sbom: ## 🛡️ Generate SBOM & security report
441438
@echo "🛡️ Generating SBOM & security report…"
@@ -459,9 +456,9 @@ check-manifest: ## 📦 Verify MANIFEST.in completeness
459456
# -----------------------------------------------------------------------------
460457
# 📑 YAML / JSON / TOML LINTERS
461458
# -----------------------------------------------------------------------------
462-
# help: yamllint - Lint YAML files (uses .yamllint)
463-
# help: jsonlint - Validate every *.json file with jq (‐‐exit-status)
464-
# help: tomllint - Validate *.toml files with tomlcheck
459+
# help: yamllint - Lint YAML files (uses .yamllint)
460+
# help: jsonlint - Validate every *.json file with jq (‐‐exit-status)
461+
# help: tomllint - Validate *.toml files with tomlcheck
465462
#
466463
# ➊ Add the new linters to the master list
467464
LINTERS += yamllint jsonlint tomllint

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ dev = [
137137
"twine>=6.1.0",
138138
"ty>=0.0.1a9",
139139
"types-tabulate>=0.9.0.20241207",
140+
"tox>=4.27.0",
141+
"tox-uv>=1.26.0",
142+
"uv>=0.7.13",
140143
]
141144

142145
# Convenience meta-extras

tox.ini

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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

Comments
 (0)