-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathnoxfile.py
More file actions
90 lines (73 loc) · 2.64 KB
/
noxfile.py
File metadata and controls
90 lines (73 loc) · 2.64 KB
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
from __future__ import annotations
import os
import shutil
from pathlib import Path
import nox
DIR = Path(__file__).parent.resolve()
nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["typecheck", "tests"]
nox.options.default_venv_backend = "uv|virtualenv"
@nox.session
def typecheck(session: nox.Session) -> None:
"""Typecheck with mypy."""
# We must install all of the extras groups so mypy can find everything it
# needs; otherwise, it will complain about missing type stubs.
session.install("--group", "test", ".[all]")
session.run("mypy")
@nox.session
def tests(session: nox.Session) -> None:
"""Run the unit tests."""
# We must install all of the extras groups because there are tests that
# test additional functionality available when the user has the extras
# installed.
session.install("--group", "test", ".[all]")
session.run(
"pytest",
"tests/unit",
"-rxXs", # Show provided reason in summary for (x)fail, (X)pass, and (s)kipped tests
*session.posargs,
)
@nox.session(name="test-min-deps", python="3.12", venv_backend="uv")
def test_min_deps(session: nox.Session) -> None:
"""Run the unit tests using the lowest compatible version of all direct dependencies."""
session.install(
"--resolution",
"lowest-direct",
"--editable",
".",
"--group",
"test",
)
session.run(
"pytest",
"tests/unit",
"-rxXs", # Show provided reason in summary for (x)fail, (X)pass, and (s)kipped tests
*session.posargs,
)
@nox.session(name="integration-tests")
def integration_tests(session: nox.Session) -> None:
"""Run the integration tests."""
session.install("--editable", ".", "--group", "test")
session.run(
"pytest",
"tests/integration",
"-rxXs", # Show provided reason in summary for (x)fail, (X)pass, and (s)kipped tests
*session.posargs,
env=dict(
EARTHDATA_USERNAME=os.environ["EARTHDATA_USERNAME"],
EARTHDATA_PASSWORD=os.environ["EARTHDATA_PASSWORD"],
),
)
@nox.session(name="build-pkg")
def build_pkg(session: nox.Session) -> None:
"""Build a source distribution and binary distribution (wheel)."""
build_path = DIR.joinpath("build")
if build_path.exists():
shutil.rmtree(build_path)
session.install("build")
session.run("python", "-m", "build")
@nox.session(name="serve-docs")
def serve_docs(session: nox.Session) -> None:
"""Build the documentation and serve it."""
session.install("--editable", ".", "--group", "docs")
session.run("mkdocs", "serve", *session.posargs)