-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnoxfile.py
More file actions
70 lines (57 loc) · 1.62 KB
/
noxfile.py
File metadata and controls
70 lines (57 loc) · 1.62 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
from pathlib import Path
import nox
package_path = Path(__file__).parent
nox.options.default_venv_backend = 'uv'
@nox.session
def pytest(session: nox.Session):
uv_sync(session)
pytest_run(session)
@nox.session
def precommit(session: nox.Session):
uv_sync(session, 'pre-commit')
session.run(
'pre-commit',
'run',
'--all-files',
)
@nox.session
def audit(session: nox.Session):
# Much faster to install the deps first and have pip-audit run against the venv
uv_sync(session)
session.run(
'pip-audit',
'--desc',
'--skip-editable',
)
def uv_sync(session: nox.Session, *groups, project=False, extra=None):
if not groups:
groups = (session.name,)
project_args = () if project or session.name.startswith('pytest') else ('--no-install-project',)
group_args = [arg for group in groups for arg in ('--group', group)]
extra_args = ('--extra', extra) if extra else ()
run_args = (
'uv',
'sync',
'--active',
'--no-default-groups',
*project_args,
*group_args,
*extra_args,
)
session.run(*run_args)
def pytest_run(session: nox.Session, *args, **env):
session.run(
'pytest',
'-ra',
'--tb=native',
'--strict-markers',
'--cov',
'--cov-config=.coveragerc',
f'--junit-xml={package_path}/ci/test-reports/{session.name}.pytests.xml',
f'--cov-report=xml:{package_path}/ci/coverage/{session.name}.xml',
'--no-cov-on-fail',
package_path / 'tests',
*args,
*session.posargs,
env=env,
)