forked from pyca/cryptography
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
146 lines (121 loc) · 3.23 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
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
136
137
138
139
140
141
142
143
144
145
146
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import annotations
import nox
nox.options.reuse_existing_virtualenvs = True
def install(session: nox.Session, *args: str) -> None:
session.install(
"-v",
"-c",
"ci-constraints-requirements.txt",
*args,
silent=False,
)
@nox.session
@nox.session(name="tests-ssh")
@nox.session(name="tests-randomorder")
@nox.session(name="tests-nocoverage")
def tests(session: nox.Session) -> None:
extras = "test"
if session.name == "tests-ssh":
extras += ",ssh"
if session.name == "tests-randomorder":
extras += ",test-randomorder"
install(session, f".[{extras}]")
install(session, "-e", "./vectors")
session.run("pip", "list")
if session.name != "tests-nocoverage":
cov_args = [
"--cov=cryptography",
"--cov=tests",
]
else:
cov_args = []
session.run(
"pytest",
"-n",
"auto",
"--dist=worksteal",
*cov_args,
"--durations=10",
*session.posargs,
"tests/",
)
@nox.session
def docs(session: nox.Session) -> None:
install(session, ".[docs,docstest,sdist,ssh]")
temp_dir = session.create_tmp()
session.run(
"sphinx-build",
"-T",
"-W",
"-b",
"html",
"-d",
f"{temp_dir}/doctrees",
"docs",
"docs/_build/html",
)
session.run(
"sphinx-build",
"-T",
"-W",
"-b",
"latex",
"-d",
f"{temp_dir}/doctrees",
"docs",
"docs/_build/latex",
)
session.run(
"sphinx-build",
"-T",
"-W",
"-b",
"doctest",
"-d",
f"{temp_dir}/doctrees",
"docs",
"docs/_build/html",
)
session.run(
"sphinx-build",
"-T",
"-W",
"-b",
"spelling",
"docs",
"docs/_build/html",
)
# This is in the docs job because `twine check` verifies that the README
# is valid reStructuredText.
session.run("python", "-m", "build", "--sdist")
session.run("twine", "check", "dist/*")
@nox.session(name="docs-linkcheck")
def docs_linkcheck(session: nox.Session) -> None:
install(session, ".[docs]")
session.run(
"sphinx-build", "-W", "-b", "linkcheck", "docs", "docs/_build/html"
)
@nox.session
def flake(session: nox.Session) -> None:
install(session, ".[pep8test,test,ssh,nox]")
session.run("ruff", ".")
session.run("black", "--check", ".")
session.run("check-sdist")
session.run(
"mypy",
"src/cryptography/",
"vectors/cryptography_vectors/",
"tests/",
"release.py",
"noxfile.py",
)
@nox.session
def rust(session: nox.Session) -> None:
install(session, ".")
with session.chdir("src/rust/"):
session.run("cargo", "fmt", "--all", "--", "--check", external=True)
session.run("cargo", "clippy", "--", "-D", "warnings", external=True)
session.run("cargo", "test", "--no-default-features", external=True)