Debian Codegraph @

noxfile.py

raw
1 import nox
2
3 nox.options.reuse_existing_virtualenvs = True
4 nox.options.default_venv_backend = "uv|virtualenv"
5
6 MINIMUM_CRYPTOGRAPHY_VERSION = "49.0.0"
7
8
9 @nox.session
10 @nox.session(name="tests-cryptography-main")
11 @nox.session(name="tests-cryptography-minimum")
12 @nox.session(name="tests-wheel")
13 @nox.session(name="tests-cryptography-minimum-wheel")
14 @nox.session(name="tests-random-order")
15 def tests(session: nox.Session) -> None:
16 cryptography_version = None
17 use_wheel = False
18 random_order = False
19
20 if "cryptography-main" in session.name:
21 cryptography_version = "main"
22 elif "cryptography-minimum" in session.name:
23 cryptography_version = "minimum"
24
25 if "wheel" in session.name:
26 use_wheel = True
27
28 if "random-order" in session.name:
29 random_order = True
30
31 deps = ["coverage>=4.2"]
32
33 if cryptography_version == "minimum":
34 deps.append(f"cryptography=={MINIMUM_CRYPTOGRAPHY_VERSION}")
35
36 if random_order:
37 deps.append("pytest-randomly")
38
39 extra_install_args = []
40 if not use_wheel:
41 extra_install_args.append("--no-binary")
42 extra_install_args.append("cryptography")
43
44 session.install(*deps)
45 session.install("-e", ".[test]", *extra_install_args)
46 if cryptography_version == "main":
47 session.install("git+https://github.com/pyca/cryptography.git")
48
49 session.run("openssl", "version", external=True)
50 session.run("coverage", "run", "--parallel", "-m", "OpenSSL.debug")
51 session.run(
52 "coverage", "run", "--parallel", "-m", "pytest", "-v", *session.posargs
53 )
54
55
56 @nox.session
57 def lint(session: nox.Session) -> None:
58 session.install("ruff")
59 session.run("ruff", "check", ".")
60 session.run("ruff", "format", "--check", ".")
61
62
63 @nox.session
64 def mypy(session: nox.Session) -> None:
65 session.install("-e", ".[test]")
66 session.install("mypy")
67 session.run("mypy", "src/", "tests/")
68
69
70 @nox.session(name="check-manifest")
71 def check_manifest(session: nox.Session) -> None:
72 session.install("check-manifest")
73 session.run("check-manifest")
74
75
76 @nox.session
77 def docs(session: nox.Session) -> None:
78 session.install("-e", ".[docs]")
79 session.run(
80 "sphinx-build",
81 "-W",
82 "-b",
83 "html",
84 "doc",
85 "doc/_build/html",
86 *session.posargs,
87 )