-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
116 lines (88 loc) · 3.08 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
import os
import nox
nox.options.reuse_existing_virtualenvs = True
@nox.session(name="format")
def format_code(session):
"""Format code with Black."""
session.install("-r", "dev-requirements.txt")
session.run("black", "calculator", "website", "worker", "data-pipelines")
def install_website_dependencies(session):
session.install("-r", "shared-requirements.txt")
session.install("-r", "website/website-requirements.txt")
session.install("-e", "./website")
session.install("-e", "./calculator")
def install_worker_dependencies(session):
session.install("-r", "shared-requirements.txt")
session.install("-r", "worker/worker-requirements.txt")
session.install("-e", "./worker")
session.install("-e", "./calculator")
WEBSITE_ENV = {
"DJANGO_SETTINGS_MODULE": "website.settings.development",
}
WORKER_ENV = {
"DJANGO_SETTINGS_MODULE": "worker.settings.development",
"GNOMAD_DATA_PATH": os.path.join(os.path.dirname(__file__), "data"),
"CLINVAR_DATA_PATH": os.path.join(os.path.dirname(__file__), "data"),
}
@nox.session
def makemigrations(session):
"""Run django-admin makemigrations."""
install_website_dependencies(session)
session.run("django-admin", "makemigrations", env=WEBSITE_ENV)
@nox.session(name="pylint:website")
def website_pylint(session):
"""Run Pylint on website and calculator directories."""
session.install("-r", "dev-requirements.txt")
install_website_dependencies(session)
session.run(
"pylint",
"--load-plugins=pylint_django",
"calculator/src/calculator",
"calculator/tests",
"website/src/website",
"website/tests",
env=WEBSITE_ENV,
)
@nox.session(name="pylint:worker")
def worker_pylint(session):
"""Run Pylint on worker directory."""
session.install("-r", "dev-requirements.txt")
install_worker_dependencies(session)
session.run(
"pylint",
"--load-plugins=pylint_django",
"worker/src/worker",
"worker/tests",
env=WORKER_ENV,
)
@nox.session(name="pylint:data-pipelines")
def data_pipelines_pylint(session):
"""Run Pylint on data-pipelines directory."""
session.install("-r", "dev-requirements.txt")
session.install("hail==0.2.120")
session.run("pylint", "data-pipelines")
@nox.session(name="tests:website")
def website_tests(session):
"""Run website and calculator tests."""
session.install("-r", "dev-requirements.txt")
install_website_dependencies(session)
session.run(
"pytest",
"calculator/tests",
env={**WEBSITE_ENV, "DJANGO_SETTINGS_MODULE": "website.settings.test"},
)
session.run(
"pytest",
"website/tests",
env={**WEBSITE_ENV, "DJANGO_SETTINGS_MODULE": "website.settings.test"},
)
@nox.session(name="tests:worker")
def worker_tests(session):
"""Run worker tests."""
session.install("-r", "dev-requirements.txt")
install_worker_dependencies(session)
session.run(
"pytest",
"worker/tests",
env={**WORKER_ENV, "DJANGO_SETTINGS_MODULE": "worker.settings.test"},
)