-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathnoxfile.py
More file actions
135 lines (109 loc) · 3.35 KB
/
noxfile.py
File metadata and controls
135 lines (109 loc) · 3.35 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
"""This module implements our CI function calls."""
import nox
@nox.session(name="test")
def run_test(session):
"""Run pytest."""
session.install(".[tests]")
session.run("pytest")
@nox.session(name="fast-test")
def run_test_fast(session):
"""Run pytest."""
session.install(".[tests]")
session.run("pytest", "-m", "not slow")
@nox.session(name="doctests")
def run_doctests(session):
"""Run tests in docstrings."""
session.install(".[tests]", "xdoctest", "pygments", "matplotlib")
session.run("xdoctest", "-m", "ptwt", "--quiet")
@nox.session(name="lint")
def lint(session):
"""Check code conventions."""
session.install("flake8")
session.install(
"flake8-black",
"flake8-docstrings",
"flake8-bugbear",
"flake8-broken-line",
"pep8-naming",
"pydocstyle",
"darglint",
)
session.run("flake8", "src", "tests", "noxfile.py")
session.install("sphinx", "doc8")
session.run("doc8", "--max-line-length", "120", "docs/")
@nox.session(name="typing")
def mypy(session):
"""Check type hints."""
session.install(".[typing]")
session.run(
"mypy",
"--install-types",
"--non-interactive",
"--ignore-missing-imports",
"--strict",
"--no-warn-return-any",
"--explicit-package-bases",
"src",
"tests",
)
@nox.session(name="docs")
def docs(session):
"""Build docs."""
session.install(".")
session.install("sphinx-book-theme")
session.install("sphinxcontrib-bibtex")
session.run(
"python",
"-m",
"sphinx",
"-W",
"-b",
"html",
"-d",
"docs/build/doctrees",
"docs/",
"docs/_build/html",
)
@nox.session(name="format")
def format(session):
"""Fix common convention problems automatically."""
session.install("black")
session.install("isort")
session.run("isort", "src", "tests", "noxfile.py")
session.run("black", "src", "tests", "noxfile.py")
@nox.session(name="coverage")
def check_coverage(session):
"""Check test coverage and generate a html report."""
session.install(".")
session.install("pytest")
session.install("coverage")
try:
session.run("coverage", "run", "-m", "pytest")
finally:
session.run("coverage", "html")
@nox.session(name="coverage-clean")
def clean_coverage(session):
"""Remove the code coverage website."""
session.run("rm", "-r", "htmlcov", external=True)
@nox.session(name="check-package")
def pyroma(session):
"""Run pyroma to check if the package is ok."""
session.install("pyroma")
session.run("pyroma", ".")
@nox.session(name="build")
def build(session):
"""Build a pip package."""
session.install("build")
session.install("setuptools")
session.run("python", "-m", "build")
@nox.session(name="finish")
def finish(session):
"""Finish this version increase the version number and upload to pypi."""
session.install("bump-my-version")
session.install("twine")
session.run("bump-my-version", "bump", "release", external=True)
build(session)
session.run("twine", "upload", "--skip-existing", "dist/*", external=True)
session.run("git", "push", external=True)
session.run("bump-my-version", "bump", "patch", external=True)
session.run("git", "push", external=True)