-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnoxfile.py
36 lines (29 loc) · 1000 Bytes
/
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
"""Nox sessions."""
import os
import nox
from nox.sessions import Session
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
nox.options.sessions = [
"pre-commit",
"tests",
]
PYTHON_VERSIONS = ["3.9", "3.10", "3.11"]
@nox.session(name="pre-commit", python=PYTHON_VERSIONS)
def precommit(session: Session) -> None:
"""Lint using pre-commit."""
args = session.posargs or [
"run",
"--all-files",
"--hook-stage=manual",
]
session.run("pdm", "install", "-G", "lint", external=True)
session.run("pre-commit", "install")
session.run("pre-commit", *args)
@nox.session(name="tests", python=PYTHON_VERSIONS)
def tests(session: Session) -> None:
"""Run the test suite."""
args = session.posargs or ["--cov"]
# install the package itself into a new virtual environment with tests dependencies
session.run("pdm", "install", "-G", "test", external=True)
# run pytest against the installed package
session.run("pytest", *args)