-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoxfile.py
More file actions
81 lines (64 loc) · 2.73 KB
/
Copy pathnoxfile.py
File metadata and controls
81 lines (64 loc) · 2.73 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
import nox
# Define default sessions
## `typecheck` is opt-in (`nox -s typecheck`) until the baseline is cleaned;
## running `nox` with no args should not fail on pre-existing diagnostics.
nox.options.sessions = ["lint", "tests", "docs"]
nox.options.default_venv_backend = "uv"
@nox.session
def tests(session):
"""Run tests."""
# Install the package in editable mode with dev dependencies
session.install("-e", ".[dev]")
# Run pytest
session.run("pytest", *session.posargs)
@nox.session
def lint(session):
"""Run linting and style checks."""
session.install("ruff")
session.run("ruff", "check", ".")
session.run("ruff", "format", "--check", ".")
@nox.session
def typecheck(session):
"""Run ty static type checker."""
# Install the package + deps so ty can resolve third-party imports.
session.install("-e", ".[dev]")
# Point ty at the session's own virtualenv.
session.run("ty", "check", "--python", session.virtualenv.location, *session.posargs)
@nox.session
def format(session):
"""Run formatters and auto-fixers."""
session.install("ruff")
session.run("ruff", "format", ".")
session.run("ruff", "check", "--fix", ".")
@nox.session
def docs(session):
"""Build the documentation."""
session.install("-e", ".[docs]")
# Build the documentation using sphinx-build directly
session.run("sphinx-build", "-b", "html", "docs/source", "docs/build/html")
@nox.session(venv_backend="none")
def lint_pins(session):
"""Fail if any consumer-facing example pins != RECOMMENDED_PIN (or uses @main)."""
from adi_lg_plugins.hw_ci._release import RECOMMENDED_PIN
from adi_lg_plugins.hw_ci.pin_lint import CONSUMER_PIN_PATHS, find_consumer_pin_violations
violations = find_consumer_pin_violations(CONSUMER_PIN_PATHS, RECOMMENDED_PIN)
for f, line, found in violations:
session.log(f"{f}:{line}: consumer pin @{found} != @{RECOMMENDED_PIN}")
if violations:
session.error(f"{len(violations)} stale consumer pin(s)")
@nox.session(venv_backend="none")
def release_guard(session):
"""RELEASE-ONLY. Fail if any hw-request-family workflow still has an @main
self-ref (i.e. scripts/pin-release-refs.sh was not run). MUST NOT run on
main — main keeps @main by design."""
from adi_lg_plugins.hw_ci.pin_lint import find_main_self_refs
family = [
".github/workflows/hw-request.yml",
".github/workflows/noos-hw-request.yml",
".github/workflows/matlab-hw-request.yml",
]
refs = find_main_self_refs(family)
for f, line in refs:
session.log(f"{f}:{line}: internal @main self-ref — run scripts/pin-release-refs.sh")
if refs:
session.error(f"{len(refs)} unpinned @main self-ref(s) — not release-ready")