-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnoxfile.py
More file actions
63 lines (46 loc) · 1.76 KB
/
noxfile.py
File metadata and controls
63 lines (46 loc) · 1.76 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
import nox
# options
nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ["lint", "typecheck", "security", "test", "yamllint"]
PYTHON_VERSIONS = ["3.12"]
# targets
TARGETS = ["src", "tests"]
def install_with_tools(session: nox.Session, *tools: str) -> None:
"""Install project and specified tools."""
session.install(".")
if tools:
session.install(*tools)
def run_tool(session: nox.Session, tool: str, *args: str) -> None:
"""Run a tool with optional args or posargs override."""
args = session.posargs or list(args) or TARGETS
session.run(tool, *args)
@nox.session(tags=["lint"])
def lint(session: nox.Session) -> None:
"""Run ruff (lint + format) and isort."""
install_with_tools(
session,
"ruff",
)
run_tool(session, "ruff", "check", "--select", "I", "--fix", *TARGETS)
@nox.session(tags=["typecheck"])
def typecheck(session: nox.Session) -> None:
"""Run mypy on source code."""
install_with_tools(session, "mypy")
run_tool(session, "mypy", "--config-file=.github/linters/.mypy.ini", *TARGETS)
@nox.session(tags=["security"])
def security(session: nox.Session) -> None:
"""Run Bandit security checks."""
install_with_tools(session, "bandit")
session.run("bandit", "-r", *TARGETS, "--skip", "B101")
@nox.session(tags=["test"])
def test(session: nox.Session) -> None:
"""Run pytest test suite."""
install_with_tools(session, "pytest", "pytest-cov", "moto", "duckdb", "sqlglot")
args = session.posargs or []
session.run("pytest", *args)
@nox.session(tags=["lint"])
def yamllint(session: nox.Session) -> None:
"""Run YAML linter."""
install_with_tools(session, "yamllint")
args = session.posargs or ["src", "tests"]
session.run("yamllint", *args)