-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnoxfile.py
More file actions
84 lines (66 loc) · 2.56 KB
/
Copy pathnoxfile.py
File metadata and controls
84 lines (66 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""Nox sessions for django-postgresql-dag."""
import sys
import nox
DJANGO_STABLE_VERSION = "5.2"
DJANGO_VERSIONS = ["5.2", "6.0"]
PYTHON_STABLE_VERSION = "3.14"
PYTHON_VERSIONS = ["3.12", "3.13", "3.14"]
PACKAGE = "django_postgresql_dag"
nox.options.default_venv_backend = "uv"
nox.options.sessions = ["pre-commit", "pip-audit", "tests"]
@nox.session(name="pre-commit", python=PYTHON_STABLE_VERSION)
def precommit(session: nox.Session) -> None:
"""Run pre-commit hooks on all files."""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files")
@nox.session(name="pip-audit", python=PYTHON_STABLE_VERSION)
def pip_audit(session: nox.Session) -> None:
"""Scan dependencies for known vulnerabilities."""
pyproject = nox.project.load_toml("pyproject.toml")
deps = nox.project.dependency_groups(pyproject, "dev")
session.install(".", *deps)
session.install("pip-audit")
session.run("pip-audit")
@nox.session(
python=PYTHON_VERSIONS,
tags=["tests"],
)
@nox.parametrize("django", DJANGO_VERSIONS)
def tests(session: nox.Session, django: str) -> None:
"""Run the test suite across Python and Django versions.
The PostgreSQL version is determined by the server at PG_HOST/PG_PORT
(set by the CI matrix), not by nox, so it is not parametrized here.
"""
pyproject = nox.project.load_toml("pyproject.toml")
deps = nox.project.dependency_groups(pyproject, "dev")
session.install(".[transforms]", *deps)
session.install(f"django~={django}.0")
session.run(
"coverage",
"run",
"-m",
"pytest",
"-vv",
*session.posargs,
)
if sys.stdin.isatty():
session.notify("coverage")
@nox.session(python=PYTHON_STABLE_VERSION)
def coverage(session: nox.Session) -> None:
"""Combine and report coverage."""
session.install("coverage[toml]")
session.run("coverage", "combine", success_codes=[0, 1])
session.run("coverage", "report")
@nox.session(name="docs-build", python=PYTHON_STABLE_VERSION)
def docs_build(session: nox.Session) -> None:
"""Build the documentation."""
session.install("-r", "docs/requirements.txt")
session.install(".")
session.run("sphinx-build", "docs", "docs/_build")
@nox.session(name="docs", python=PYTHON_STABLE_VERSION)
def docs(session: nox.Session) -> None:
"""Build and serve the documentation with live reload."""
session.install("-r", "docs/requirements.txt")
session.install("sphinx-autobuild")
session.install(".")
session.run("sphinx-autobuild", "docs", "docs/_build", "--open-browser")