-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
59 lines (48 loc) · 1.42 KB
/
noxfile.py
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
import nox
from pathlib import Path
import shutil
# Ensure that nox supports session tags.
nox.needs_version = '>=2022.8.7'
@nox.session()
def build(session):
"""Build source and binary (wheel) packages."""
build_dir = Path('build')
if build_dir.exists():
shutil.rmtree(build_dir)
session.install('build')
session.run('python', '-m', 'build')
@nox.session()
def tests(session):
"""Run test cases and record the test coverage."""
session.install('.[tests]')
# Run the test cases and report the test coverage.
package = 'parq'
session.run(
'python3',
'-bb',
Path(session.bin) / 'pytest',
f'--cov={package}',
'--pyargs',
package,
'./tests',
'./doc',
*session.posargs,
env={
# NOTE: Do not import sphinx_rtd_theme in doc/conf.py.
'READTHEDOCS': 'True',
},
)
@nox.session()
def docs(session):
"""Build the HTML documentation."""
session.install('-r', 'requirements-rtd.txt')
session.run(
'sphinx-build', '-W', '-b', 'html', './doc', './doc/build/html'
)
@nox.session(tags=['check'])
def ruff(session):
"""Check code for linter warnings and formatting issues."""
check_files = ['src', 'tests', 'doc', 'noxfile.py']
session.install('ruff ~= 0.1.2')
session.run('ruff', 'check', *check_files)
session.run('ruff', 'format', '--diff', *check_files)