Repository navigation
Expand file tree
/
Copy pathnoxfile.py
More file actions
156 lines (129 loc) · 3.79 KB
/
Copy pathnoxfile.py
File metadata and controls
156 lines (129 loc) · 3.79 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
from nox import Session, options, param, parametrize
from nox_uv import session
options.error_on_external_run = True
options.default_venv_backend = "uv"
options.sessions = ["lint", "type_check", "test", "docs"]
@session(
python=["3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"],
uv_groups=["test"],
)
def test(s: Session) -> None:
s.run(
"pytest",
"--cov=ical2jcal",
"--cov-report=html",
"--cov-report=term",
"--cov-fail-under=95",
"tests",
*s.posargs,
)
# For some sessions, set venv_backend="none" to simply execute scripts within the existing outer
# uv-generated virtual environment, rather than have nox create a new one for each session. This
# makes commonly repeated sessions execute faster.
@session(venv_backend="none")
@parametrize(
"command",
[
param(
[
"ruff",
"check",
".",
"--select",
"I",
# Also remove unused imports.
"--select",
"F401",
"--extend-fixable",
"F401",
"--fix",
],
id="sort_imports",
),
param(["ruff", "format", "."], id="format"),
],
)
def fmt(s: Session, command: list[str]) -> None:
s.run(*command)
@session(venv_backend="none")
@parametrize(
"command",
[
param(["ruff", "check", "."], id="lint_check"),
param(["ruff", "format", "--check", "."], id="format_check"),
],
)
def lint(s: Session, command: list[str]) -> None:
s.run(*command)
@session(venv_backend="none")
def lint_fix(s: Session) -> None:
s.run("ruff", "check", ".", "--extend-fixable", "F401", "--fix")
@session(venv_backend="none")
def type_check(s: Session) -> None:
s.run("mypy", "src", "tests", "noxfile.py")
# Environment variable needed for mkdocstrings-python to locate source files.
doc_env = {"PYTHONPATH": "src"}
def update_cmd_docs(s: Session) -> None:
"""Update the documentation from Python docstrings."""
s.run(
"typer",
"--app",
"ical2jcal",
"ical2jcal.cli",
"utils",
"docs",
"--name",
"ical2jcal",
"--output",
"docs/ical2jcal.md",
)
s.run(
"typer",
"--app",
"jcal2ical",
"ical2jcal.cli",
"utils",
"docs",
"--name",
"jcal2ical",
"--output",
"docs/jcal2ical.md",
)
@session(venv_backend="none")
def docs(s: Session) -> None:
update_cmd_docs(s)
s.run("mkdocs", "build", env=doc_env)
@session(venv_backend="none")
def docs_check_urls(s: Session) -> None:
update_cmd_docs(s)
s.run("mkdocs", "build", env=doc_env | {"HTMLPROOFER_VALIDATE_EXTERNAL_URLS": str(True)})
@session(venv_backend="none")
def docs_offline(s: Session) -> None:
update_cmd_docs(s)
s.run("mkdocs", "build", env=doc_env | {"MKDOCS_MATERIAL_OFFLINE": str(True)})
@session(venv_backend="none")
def docs_serve(s: Session) -> None:
update_cmd_docs(s)
s.run("mkdocs", "serve", env=doc_env)
@session(venv_backend="none")
def docs_github_pages(s: Session) -> None:
update_cmd_docs(s)
s.run("mkdocs", "gh-deploy", "--force", env=doc_env)
# Install only main dependencies for the license report.
@session(uv_groups=["licenses"], uv_no_install_project=True)
def licenses(s: Session) -> None:
s.run(
"pip-licenses",
"--format=markdown",
"--output-file=./docs/licenses/summary.txt",
*s.posargs,
)
s.run(
"pip-licenses",
"--format=plain-vertical",
"--with-license-files",
"--no-license-path",
"--output-file=./docs/licenses/license_files.txt",
)
s.run("pip-licenses", *s.posargs)
s.run("pip-licenses", "--summary")