|
| 1 | +#!/usr/bin/env -S uv run --script |
| 2 | + |
| 3 | +# /// script |
| 4 | +# dependencies = ["nox>=2025.11.12"] |
| 5 | +# /// |
| 6 | + |
| 7 | +import nox |
| 8 | + |
| 9 | +# Tags: |
| 10 | +# test-min - for local testing of min deps |
| 11 | +# test-max - for local testing of max deps |
| 12 | +# pr - for pull-requests |
| 13 | +# pr-matrix - for pull-requests, will us OS matrix |
| 14 | + |
| 15 | + |
| 16 | +# [*((python-version, uv-resolution), [*tags])] |
| 17 | +MATRIX = [ |
| 18 | + (("3.10", "lowest-direct"), ["test-min", "pr-matrix"]), |
| 19 | + (("3.10", "highest"), []), |
| 20 | + (("3.11", "highest"), []), |
| 21 | + (("3.12", "highest"), ["pr-matrix"]), |
| 22 | + (("3.13", "highest"), []), |
| 23 | + (("3.14", "highest"), ["test-max", "pr-matrix"]), |
| 24 | +] |
| 25 | + |
| 26 | + |
| 27 | +def setup_uv(session: nox.Session, resolution="highest") -> None: |
| 28 | + """ |
| 29 | + IMPORTANT: make sure to set `venv_backend="uv"` on @nox.session(). |
| 30 | + """ |
| 31 | + session.run_install( |
| 32 | + "uv", |
| 33 | + "sync", |
| 34 | + f"--resolution={resolution}", |
| 35 | + f"--python={session.virtualenv.location}", |
| 36 | + env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}, |
| 37 | + ) |
| 38 | + |
| 39 | + |
| 40 | +@nox.session(venv_backend="uv", tags=["pr", "lint"]) |
| 41 | +def lint(session: nox.Session) -> None: |
| 42 | + """ |
| 43 | + Run the linters |
| 44 | + """ |
| 45 | + setup_uv(session) |
| 46 | + session.run("ruff", "check", *session.posargs) |
| 47 | + |
| 48 | + |
| 49 | +@nox.session(venv_backend="uv") |
| 50 | +@nox.parametrize( |
| 51 | + "python,resolution", |
| 52 | + [x[0] for x in MATRIX], |
| 53 | + ids=['py' + ':'.join(x[0]) for x in MATRIX], |
| 54 | + tags=[x[1] for x in MATRIX], |
| 55 | +) |
| 56 | +def test(session: nox.Session, resolution) -> None: |
| 57 | + """ |
| 58 | + Run the tests (can use `-t test-min` or `-t test-max` to filter) |
| 59 | + """ |
| 60 | + setup_uv(session, resolution) |
| 61 | + session.run("pytest", *session.posargs, '-v') |
0 commit comments