generated from 12rambau/pypackage
-
Notifications
You must be signed in to change notification settings - Fork 1
/
noxfile.py
77 lines (57 loc) · 2.41 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
"""All the process that can be run using nox.
The nox run are build in isolated environment that will be stored in .nox. to force the venv update, remove the .nox/xxx folder.
"""
import datetime
import fileinput
import nox
nox.options.sessions = ["lint", "test", "docs", "mypy"]
@nox.session(reuse_venv=True)
def lint(session):
"""Apply the pre-commits."""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", *session.posargs)
@nox.session(reuse_venv=True)
def test(session):
"""Run the selected tests and report coverage in html."""
session.install(".[test]")
test_files = session.posargs or ["tests"]
session.run("pytest", "--color=yes", "--cov", "--cov-report=html", *test_files)
@nox.session(reuse_venv=True, name="ci-test")
def ci_test(session):
"""Run all the test and report coverage in xml."""
session.install(".[test]")
session.posargs[0] if session.posargs else "default"
session.run("pytest", "--color=yes", "--cov", "--cov-report=xml")
@nox.session(reuse_venv=True, name="dead-fixtures")
def dead_fixtures(session):
"""Check for dead fixtures within the tests."""
session.install(".[test]")
session.run("pytest", "--dead-fixtures")
@nox.session(reuse_venv=True)
def docs(session):
"""Build the documentation."""
build = session.posargs.pop() if session.posargs else "html"
session.install(".[doc]")
session.run("sphinx-build", "-v", "-b", build, "docs", f"docs/_build/{build}")
@nox.session(name="mypy", reuse_venv=True)
def mypy(session):
"""Run a mypy check of the lib."""
session.install("mypy")
test_files = session.posargs or ["qutree"]
session.run("mypy", *test_files)
@nox.session(reuse_venv=True)
def stubgen(session):
"""Generate stub files for the lib but requires human attention before merge."""
session.install("mypy")
package = session.posargs or ["qutree"]
session.run("stubgen", "-p", package[0], "-o", "stubs", "--include-private")
@nox.session(name="release-date", reuse_venv=True)
def release_date(session):
"""Update the release date of the citation file."""
current_date = datetime.datetime.now().strftime("%Y-%m-%d")
with fileinput.FileInput("CITATION.cff", inplace=True) as file:
for line in file:
if line.startswith("date-released:"):
print(f'date-released: "{current_date}"')
else:
print(line, end="")