forked from dod-cyber-crime-center/Dragodis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
65 lines (52 loc) · 1.66 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
"""
Runs tests and other routines.
Usage:
1. Install "nox"
2. Run "nox" or "nox -s test"
"""
import shutil
import os
import nox
def _install_local_deps(session):
"""Install local dc3 dependencies."""
for path in ["../dc3_pyhidra_github"]:
if os.path.exists(path):
session.install(path)
@nox.session(python="3.8")
def test(session):
"""Run pytests"""
_install_local_deps(session)
session.install("-e", ".[testing]")
session.run("pytest")
@nox.session(python="3.8")
def build(session):
"""Build source and wheel distribution"""
session.run("python", "setup.py", "sdist")
session.run("python", "setup.py", "bdist_wheel")
@nox.session
def doc(session):
"""Builds Sphinx documentation"""
session.run("mkdir", "-p", "dist", external=True)
shutil.rmtree("docs/_build", ignore_errors=True)
shutil.rmtree("dist/docs", ignore_errors=True)
session.install("sphinx")
session.install("sphinx-rtd-theme")
session.install("myst-parser")
_install_local_deps(session)
session.install("-e", ".")
# Autodoc
shutil.rmtree("docs/api")
session.run("sphinx-apidoc", "-o", "docs/api", "dragodis/interface", "--separate")
# Build html site
session.run("sphinx-build", "docs", "docs/_build/html", "-b", "html")
shutil.copytree("docs/_build/html", f"dist/docs")
@nox.session(python=False)
def release_patch(session):
"""Generate release patch"""
session.run("mkdir", "-p", "dist", external=True)
with open("./dist/updates.patch", "w") as out:
session.run(
"git", "format-patch", "--stdout", "master",
external=True,
stdout=out
)