-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
103 lines (84 loc) · 2.77 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
# -*- coding: utf-8 -*-
"""Nox session configuration."""
import nox
from nox.sessions import Session
PACKAGE: str = "scripts"
LOCATIONS: list[str] = [
PACKAGE,
"noxfile.py",
"tests",
]
VERSIONS: list[str] = ["3.9"]
PIP_PARAMS: list[str] = ["-r"]
CONDA_PARAMS: list[str] = ["-c", "bioconda", "-c", "conda-forge", "--file"]
nox.options.stop_on_first_error = True
nox.options.default_venv_backend = "virtualenv"
nox.options.reuse_existing_virtualenvs = False
nox.options.sessions = ["form", "lint", "type", "security", "tests", "doc_tests"]
@nox.session(python=VERSIONS[0])
def form(session: Session) -> None:
"""Format code with isort and black."""
args = session.posargs or LOCATIONS
session.install(*PIP_PARAMS, "environments/form.txt")
session.run("isort", *args)
session.run("black", *args)
@nox.session(python=VERSIONS)
def lint(session: Session) -> None:
"""Lint files with flake8."""
args = session.posargs or LOCATIONS
session.install(*PIP_PARAMS, "environments/lint.txt")
session.run("pflake8", *args)
@nox.session(python=VERSIONS)
def type(session: Session) -> None:
"""Type check files with mypy."""
args = session.posargs or LOCATIONS
session.install(*PIP_PARAMS, "environments/type.txt")
session.run(
"mypy",
"--ignore-missing-imports",
"--disable-error-code",
"name-defined",
*args
)
# The snakemake install is complex, and runs better in conda
@nox.session(python=VERSIONS, venv_backend="conda")
def security(session: Session) -> None:
"""Check security safety."""
args = session.posargs or []
session.conda_install(*CONDA_PARAMS, "environments/security.txt")
session.run("safety", "check", "--bare", *args)
@nox.session(python=VERSIONS)
def tests(session: Session) -> None:
"""Run the test suite with pytest."""
args = session.posargs or []
session.install(*PIP_PARAMS, "environments/tests.txt")
session.run("pytest", *args)
@nox.session(python=VERSIONS)
def doc_tests(session: Session) -> None:
"""Test the docs.
As xdoctest does not seem to detect if multiple sources are passed,
session run must be called over each source manually.
Parameters
----------
session : Session
nox session
"""
args = session.posargs or []
command = [
"python",
"-m",
"xdoctest",
"--verbose",
"2",
"--report",
"cdiff",
"--nocolor",
]
session.install(*PIP_PARAMS, "environments/doc_tests.txt")
for x in LOCATIONS:
session.run(*command, x, *args)
@nox.session(python="3.9")
def doc_build(session: Session) -> None:
"""Build the docs."""
session.install(*PIP_PARAMS, "environments/doc_build.txt")
session.run("sphinx-build", "docs", "docs/_build")