-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
76 lines (65 loc) · 2.04 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
"""Nox configuration."""
from __future__ import annotations
from pathlib import Path
from tempfile import TemporaryDirectory
import nox
nox.needs_version = ">=2024.4.15"
nox.options.default_venv_backend = "uv|virtualenv"
STREAM_TYPES = ["REST", "GraphQL"]
AUTH_METHODS = [
"Bearer Token",
"JWT",
"API Key",
"Basic Auth",
"OAuth2",
"Custom or N/A",
]
VISIBILITIES = ["private", "public"]
RUFF_OVERRIDES = """\
extend = "./pyproject.toml"
[lint]
extend-ignore = ["TD003"]
"""
python_versions = ["3.12", "3.11", "3.10", "3.9", "3.8"]
@nox.session(python=python_versions)
@nox.parametrize("stream_type", STREAM_TYPES)
@nox.parametrize("auth_method", AUTH_METHODS)
@nox.parametrize("visibility", VISIBILITIES)
def lint(
session: nox.sessions.Session,
stream_type: str,
auth_method: str,
visibility: str,
) -> None:
"""Lint generated project."""
ref = session.posargs[0] if session.posargs else "HEAD"
with TemporaryDirectory() as tmpdir:
session.run(
"copier",
"copy",
".",
tmpdir,
"--UNSAFE",
f"--vcs-ref={ref}",
"--force",
"--defaults",
"-d",
f"python_main_version='{session.python}'",
"-d",
f"tap_stream_type={stream_type}",
"-d",
f"tap_auth_method={auth_method}",
"-d",
f"repository_visibility={visibility}",
external=True,
)
ruff_toml_path = Path(tmpdir).joinpath("ruff.toml")
with ruff_toml_path.open("w") as ruff_toml:
ruff_toml.write(RUFF_OVERRIDES)
with session.cd(tmpdir):
session.run("git", "init", external=True)
session.run("git", "add", ".", external=True)
session.run("hatch", "run", "test:dependencies", external=True)
session.run("hatch", "run", "typing:check", external=True)
session.run("cat", "pyproject.toml", external=True)
session.run("pre-commit", "run", "--all", external=True)