forked from nsidc/earthaccess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
83 lines (66 loc) · 2.58 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
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."""
session.install("--editable", ".[test]")
session.run("mypy")
@nox.session
def tests(session: nox.Session) -> None:
"""Run the unit tests."""
session.install("--editable", ".[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="test-min-deps", python="3.10", 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", ".[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", ".[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"],
),
external=True,
# NOTE: integration test are permitted to pass if the failure rate was less than a hardcoded threshold.
# PyTest will return 99 if there were some failures, but less than the threshold. For more details, see:
# `pytest_sessionfinish` in tests/integration/conftest.py
success_codes=[0, 99],
)
@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", ".[docs]")
session.run("mkdocs", "serve", *session.posargs)