-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
103 lines (88 loc) · 2.71 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
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
import functools
import os
import nox
nox.options.envdir = "build/nox"
nox.options.sessions = ["lint", "tests", "mypy", "docs", "build"]
VERSIONS = ["3.11", "3.12"]
@nox.session(python=VERSIONS)
def tests(session):
tmpdir = session.create_tmp()
session.install("-r", "requirements-tests.txt")
session.install("-e", ".")
tests = session.posargs or ["gather.tests"]
session.run(
"coverage",
"run",
"--branch",
"--source=gather",
"-m",
"virtue",
*tests,
env=dict(COVERAGE_FILE=os.path.join(tmpdir, "coverage"), TMPDIR=tmpdir),
)
fail_under = "--fail-under=100"
session.run(
"coverage",
"report",
fail_under,
"--show-missing",
"--skip-covered",
env=dict(COVERAGE_FILE=os.path.join(tmpdir, "coverage")),
)
@nox.session(python=VERSIONS[-1])
def build(session):
session.install("build")
session.run("python", "-m", "build", "--wheel")
@nox.session(python=VERSIONS[-1])
def lint(session):
files = ["src/", "noxfile.py"]
session.install("-r", "requirements-lint.txt")
session.install("-e", ".")
session.run("black", "--check", "--diff", *files)
black_compat = ["--max-line-length=88", "--ignore=E203,E501"]
session.run("flake8", *black_compat, "src/")
session.run(
"pylint",
"--disable=all",
"--enable=missing-class-docstring",
"--enable=missing-function-docstring",
"--enable=missing-module-docstring",
"--enable=function-redefined",
"src",
)
@nox.session(python=VERSIONS[-1])
def mypy(session):
session.install("-r", "requirements-mypy.txt")
session.install("-e", ".")
session.run(
"mypy",
"--warn-unused-ignores",
"--ignore-missing-imports",
"src/",
)
@nox.session(python=VERSIONS[-1])
def docs(session):
"""Build the documentation."""
output_dir = os.path.abspath(os.path.join(session.create_tmp(), "output"))
doctrees, html = map(
functools.partial(os.path.join, output_dir), ["doctrees", "html"]
)
session.run("rm", "-rf", output_dir, external=True)
session.install("-r", "requirements-docs.txt")
session.install("-e", ".")
sphinx = ["sphinx-build", "-b", "html", "-W", "-d", doctrees, ".", html]
session.cd("doc")
session.run(*sphinx)
@nox.session(python=VERSIONS[-1])
def refresh_deps(session):
"""Refresh the requirements-*.txt files"""
session.install("pip-tools")
for deps in ["tests", "docs", "lint", "mypy"]:
session.run(
"pip-compile",
"--extra",
deps,
"pyproject.toml",
"--output-file",
f"requirements-{deps}.txt",
)