-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnoxfile.py
127 lines (99 loc) · 3.42 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from __future__ import annotations
import nox
from nox import Session
PYTHONS_TESTS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
PYTHONS_BASE = ["3.10"]
nox.options.reuse_existing_virtualenvs = False
@nox.session(python=PYTHONS_TESTS)
def tests(session: Session) -> None:
# Create reports folder for pytest & coverage
session.run("mkdir", "-p", f"reports/pytest/{session.name}", external=True)
session.run("mkdir", "-p", f"reports/coverage/{session.name}", external=True)
# Remove pytest cache directory
session.run("rm", "-fr", ".pytest_cache", external=True)
# Install tests dependencies
session.install("pytest", "coverage", "pymongo")
# Run pytest without dateparser
session.run(
"coverage",
"run",
f"--data-file=./reports/coverage/{session.name}/.coverage",
"-m",
"pytest",
f"--junitxml=./reports/pytest/{session.name}/junit.xml"
f"--junit-prefix={session.name}",
"-vv",
)
# Install dateparser extra dep
session.install("dateparser")
# Run pytest with dateparser
session.run(
"coverage",
"run",
f"--data-file=./reports/coverage/{session.name}/.coverage.extra",
"-m",
"pytest",
f"--junitxml=./reports/pytest/{session.name}/junit-extra.xml"
f"--junit-prefix={session.name}",
"-vv",
)
# Combine coverage
session.run(
"coverage",
"combine",
"--append",
f"--data-file=./reports/coverage/{session.name}/.coverage.full",
f"./reports/coverage/{session.name}/.coverage",
f"./reports/coverage/{session.name}/.coverage.extra",
)
# Generate coverage HTML result
session.run(
"coverage",
"html",
f"--data-file=./reports/coverage/{session.name}/.coverage.full",
f"--directory=./reports/coverage/{session.name}/html",
)
# Generate coverage XML result
session.run(
"coverage",
"xml",
f"--data-file=./reports/coverage/{session.name}/.coverage.full",
f"-o ./reports/coverage/{session.name}/coverage-{session.name}-full.xml",
)
# Display coverage report
session.run(
"coverage",
"report",
f"--data-file=./reports/coverage/{session.name}/.coverage.full",
)
@nox.session(python=PYTHONS_BASE)
def lints(session: Session) -> None:
# Create reports folder for flake8
session.run("mkdir", "-p", f"reports/flake8/{session.name}", external=True)
# Install lints dependencies
session.install("pylint", "flake8>=4.0.0,<5.0.0", "flake8-html==0.4.2")
# Run flake8
session.run(
"flake8",
"mongo_queries_manager",
"--format=html",
f"--htmldir=./reports/flake8/{session.name}",
)
# Run pylint
session.run("pylint", "mongo_queries_manager")
@nox.session(python=PYTHONS_BASE)
def formats(session: Session) -> None:
# Install formats dependencies
session.install("black", "isort")
# Run black
session.run("black", "mongo_queries_manager", "--check")
# Run isort
session.run("isort", "mongo_queries_manager", " --check")
@nox.session(python=PYTHONS_BASE)
def types(session: Session) -> None:
# Install types dependencies
session.install("dateparser", "mypy", "types-dateparser")
# Remove mypy cache directory
session.run("rm", "-fr", ".mypy_cache", external=True)
# Run mypy
session.run("mypy", "mongo_queries_manager")