-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnoxfile.py
67 lines (52 loc) · 1.94 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
import nox
import shutil
from pathlib import Path
# Default tag for docker images
TAG = "latest"
@nox.session
def image(session: nox.Session) -> None:
"""Build docker image"""
session.run("docker", "build", "-t", f"gitstats:{TAG}", ".", external=True)
@nox.session
def publish_image(session: nox.Session) -> None:
"""Publish docker image to ghcr"""
image(session) # Build the image first
session.run(
"docker",
"tag",
f"gitstats:{TAG}",
f"ghcr.io/shenxianpeng/gitstats:{TAG}",
external=True,
)
session.run("docker", "push", f"ghcr.io/shenxianpeng/gitstats:{TAG}", external=True)
@nox.session(name="install-deps")
def install_deps(session: nox.Session) -> None:
"""Install gnuplot"""
session.run("sudo", "apt", "update", "-y", external=True)
session.run("sudo", "apt", "install", "gnuplot", "-y", external=True)
@nox.session
def build(session: nox.Session) -> None:
"""Generate gitstats report and json file"""
report_dir = Path("test-report")
if report_dir.exists():
shutil.rmtree(report_dir)
session.install("--upgrade", "pip")
session.install("-e", ".")
session.run("gitstats", ".", str(report_dir), "-f", "json", external=True)
@nox.session
def preview(session: nox.Session) -> None:
"""Preview gitstats report in local"""
build(session) # Generate report first
session.run(
"python3", "-m", "http.server", "8000", "-d", "test-report", external=True
)
@nox.session
def docs(session: nox.Session) -> None:
"""Build docs"""
session.install("--upgrade", "pip")
session.install("-r", "docs/requirements.txt")
session.run("sphinx-build", "-b", "html", "docs/source", "docs/build/html")
@nox.session(name="docs-live")
def docs_live(session: nox.Session) -> None:
session.install("-r", "docs/requirements.txt", "sphinx-autobuild")
session.run("sphinx-autobuild", "docs/source", "docs/build/html", external=True)