forked from cs01/gdbgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
182 lines (142 loc) · 4.82 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import subprocess
from pathlib import Path
from sys import platform
import nox # type: ignore
nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ["tests", "lint", "docs"]
python = ["3.6", "3.7", "3.8"]
prettier_command = [
"npx",
"--parser",
"typescript",
"--config",
".prettierrc.js",
"gdbgui/src/js/**/*",
]
doc_dependencies = [".", "mkdocs", "mkdocs-material"]
lint_dependencies = [
"black==20.8b1",
"vulture",
"flake8",
"mypy==0.782",
"check-manifest",
]
vulture_whitelist = ".vulture_whitelist.py"
files_to_lint = ["gdbgui", "tests"] + [str(p) for p in Path(".").glob("*.py")]
files_to_lint.remove(vulture_whitelist)
publish_deps = ["setuptools", "wheel", "twine"]
@nox.session(reuse_venv=True)
def python_tests(session):
session.install(".", "pytest", "pytest-cov")
tests = session.posargs or ["tests"]
session.run(
"pytest", "--cov=gdbgui", "--cov-config", ".coveragerc", "--cov-report=", *tests
)
session.notify("cover")
@nox.session(reuse_venv=True)
def js_tests(session):
session.run("yarn", "install", external=True)
session.run("yarn", "test", external=True)
session.run("yarn", "build", external=True)
@nox.session(reuse_venv=True, python=python)
def tests(session):
python_tests(session)
js_tests(session)
@nox.session(reuse_venv=True)
def cover(session):
"""Coverage analysis"""
session.install("coverage")
session.run(
"coverage",
"report",
"--show-missing",
"--omit=gdbgui/SSLify.py",
"--fail-under=20",
)
session.run("coverage", "erase")
@nox.session()
def vulture(session):
"""Find dead code"""
session.install("vulture")
session.run(
"vulture",
"--ignore-decorators",
"@app.*,@socketio.*,@nox.*,@blueprint.*",
*files_to_lint,
vulture_whitelist,
*session.posargs,
)
@nox.session()
def lint(session):
session.install(".", *lint_dependencies)
session.run("black", "--check", *files_to_lint)
session.run("flake8", *files_to_lint)
session.run("mypy", *files_to_lint)
vulture(session)
session.run("check-manifest", "--ignore", "gdbgui/static/js/*")
session.run("python", "setup.py", "check", "--metadata", "--strict")
session.run(*prettier_command, "--check", external=True)
@nox.session(reuse_venv=True)
def autoformat(session):
session.install(*lint_dependencies)
session.run("black", *files_to_lint)
session.run(*prettier_command, "--write", external=True)
@nox.session(reuse_venv=True)
def docs(session):
session.install(*doc_dependencies)
session.run("mkdocs", "build")
@nox.session(reuse_venv=True)
def develop(session):
session.install("-e", ".")
session.run("yarn", "install", external=True)
print("Watching JavaScript file and Python files for changes")
with subprocess.Popen(["yarn", "start"]):
session.run("python", "-m", "gdbgui")
@nox.session(reuse_venv=True)
def serve(session):
session.install("-e", ".")
session.run("python", "-m", "gdbgui", *session.posargs)
@nox.session(reuse_venv=True)
def build(session):
session.install(*publish_deps)
session.run("rm", "-rf", "dist", "build", external=True)
session.run("yarn", "build", external=True)
session.run("python", "setup.py", "--quiet", "sdist", "bdist_wheel")
session.run("twine", "check", "dist/*")
@nox.session(reuse_venv=True)
def publish(session):
session.install(*publish_deps)
build(session)
print("REMINDER: Has the changelog been updated?")
session.run("python", "-m", "twine", "upload", "dist/*")
publish_docs(session)
@nox.session(reuse_venv=True)
def watch_docs(session):
session.install(*doc_dependencies)
session.run("mkdocs", "serve")
@nox.session(reuse_venv=True)
def publish_docs(session):
session.install(*doc_dependencies)
session.run("mkdocs", "gh-deploy")
@nox.session(reuse_venv=True)
def build_executable_current_platform(session):
session.run("yarn", "install", external=True)
session.run("yarn", "build", external=True)
session.install(".", "PyInstaller<3.7")
session.run("python", "make_executable.py")
@nox.session(reuse_venv=True)
def build_executable_mac(session):
if not platform.startswith("darwin"):
raise Exception(f"Unexpected platform {platform}")
session.notify("build_executable_current_platform")
@nox.session(reuse_venv=True)
def build_executable_linux(session):
if not platform.startswith("linux"):
raise Exception(f"Unexpected platform {platform}")
session.notify("build_executable_current_platform")
@nox.session(reuse_venv=True)
def build_executable_windows(session):
if not platform.startswith("win32"):
raise Exception(f"Unexpected platform {platform}")
session.notify("build_executable_current_platform")