forked from meltano/meltano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
109 lines (87 loc) · 2.46 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"""Nox configuration."""
from __future__ import annotations
import os
import sys
from pathlib import Path
from random import randint
from textwrap import dedent
try:
from nox_poetry import Session
from nox_poetry import session as nox_session
except ImportError:
message = f"""\
Nox failed to import the 'nox-poetry' package.
Please install it using the following command:
{sys.executable} -m pip install nox-poetry"""
raise SystemExit(dedent(message)) from None
package = "meltano"
python_versions = ["3.11", "3.10", "3.9", "3.8", "3.7"]
main_python_version = "3.10"
locations = "src", "tests", "noxfile.py"
@nox_session(python=python_versions)
def tests(session: Session) -> None:
"""Execute pytest tests and compute coverage.
Args:
session: Nox session.
"""
backend_db = os.environ.get("PYTEST_BACKEND", "sqlite")
if backend_db == "mssql":
session.install(".[mssql,azure,gcs,s3]")
else:
session.install(".[azure,gcs,s3]")
session.install(
"colorama", # colored output in Windows
"freezegun",
"mock",
"pytest",
"pytest-asyncio",
"pytest-cov",
"pytest-docker",
"pytest-order",
"pytest-randomly",
"pytest-structlog",
"pytest-xdist",
"requests-mock",
)
session.run(
"pytest",
f"--randomly-seed={randint(0, 2**32-1)}", # noqa: S311, WPS432
*session.posargs,
env={"NOX_CURRENT_SESSION": "tests"},
)
@nox_session(python=main_python_version)
def coverage(session: Session) -> None:
"""Upload coverage data.
Args:
session: Nox session.
"""
args = session.posargs or ["report"]
session.install("coverage[toml]")
if not session.posargs and any(Path().glob(".coverage.*")):
session.run("coverage", "combine")
session.run("coverage", *args)
@nox_session(python=main_python_version)
def mypy(session: Session) -> None:
"""Run mypy type checking.
Args:
session: Nox session.
"""
args = session.posargs or [
"src/meltano",
"--exclude",
"src/meltano/migrations/",
"--exclude",
".nox/",
]
session.install(".")
session.install(
"boto3-stubs[essential]",
"mypy",
"sqlalchemy2-stubs",
"types-croniter",
"types-jsonschema",
"types-psutil",
"types-PyYAML",
"types-requests",
)
session.run("mypy", *args)