-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
40 lines (29 loc) · 1.1 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
"""Automation using nox."""
import glob
import nox
nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = "lint", "tests"
locations = "pytest_test_utils", "tests.py"
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"])
def tests(session: nox.Session) -> None:
session.install(".[tests]")
# `pytest --cov` will start coverage after pytest
# so we need to use `coverage`.
session.run("coverage", "run", "-m", "pytest")
session.run("coverage", "report", "--show-missing", "--skip-covered")
@nox.session
def lint(session: nox.Session) -> None:
session.install("pre-commit")
session.install("-e", ".[dev]")
if session.posargs:
args = [*session.posargs, "--all-files"]
else:
args = ["--all-files", "--show-diff-on-failure"]
session.run("pre-commit", "run", *args)
session.run("python", "-m", "mypy")
@nox.session
def build(session: nox.Session) -> None:
session.install("build", "setuptools", "twine")
session.run("python", "-m", "build")
dists = glob.glob("dist/*")
session.run("twine", "check", *dists, silent=True)