This repository has been archived by the owner on Sep 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnoxfile.py
129 lines (104 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
import webbrowser
from pathlib import Path
import nox
ROOT = Path(__file__).parent
LOCAL_DOC = ROOT / "doc"
nox.options.sessions = []
def _build_html_doc(session: nox.Session):
session.run("sphinx-apidoc", "-T", "-e", "-o", "api", "../exasol_bucketfs_utils_python")
session.run("sphinx-build", "-b", "html", "-W", ".", ".build-docu")
def _open_docs_in_browser(session: nox.Session):
index_file_path = Path(".build-docu/index.html").resolve()
webbrowser.open_new_tab(index_file_path.as_uri())
@nox.session(name="build-html-doc", python=False)
def build_html_doc(session: nox.Session):
"""Build the documentation for current checkout"""
with session.chdir(LOCAL_DOC):
_build_html_doc(session)
@nox.session(name="open-html-doc", python=False)
def open_html_doc(session: nox.Session):
"""Open the documentation for current checkout in the browser"""
with session.chdir(LOCAL_DOC):
_open_docs_in_browser(session)
@nox.session(name="build-and-open-html-doc", python=False)
def build_and_open_html_doc(session: nox.Session):
"""Build and open the documentation for current checkout in browser"""
with session.chdir(LOCAL_DOC):
_build_html_doc(session)
_open_docs_in_browser(session)
@nox.session(name="commit-pages-main", python=False)
def commit_pages_main(session: nox.Session):
"""
Generate the GitHub pages documentation for the main branch and
commit it to the branch github-pages/main
"""
with session.chdir(ROOT):
session.run("sgpg",
"--target_branch", "github-pages/main",
"--push_origin", "origin",
"--push_enabled", "commit",
"--source_branch", "main",
"--module_path", "${StringArray[@]}",
env={"StringArray": ("../exasol-bucketfs-utils-python")})
@nox.session(name="commit-pages-current", python=False)
def commit_pages_current(session: nox.Session):
"""
Generate the GitHub pages documentation for the current branch and
commit it to the branch github-pages/<current_branch>
"""
branch = session.run("git", "branch", "--show-current", silent=True)
with session.chdir(ROOT):
session.run("sgpg",
"--target_branch", "github-pages/" + branch[:-1],
"--push_origin", "origin",
"--push_enabled", "commit",
"--module_path", "${StringArray[@]}",
env={"StringArray": ("../exasol-bucketfs-utils-python")})
@nox.session(name="push-pages-main", python=False)
def push_pages_main(session: nox.Session):
"""
Generate the GitHub pages documentation for the main branch and
pushes it to the remote branch github-pages/main
"""
with session.chdir(ROOT):
session.run("sgpg",
"--target_branch", "github-pages/main",
"--push_origin", "origin",
"--push_enabled", "push",
"--source_branch", "main",
"--module_path", "${StringArray[@]}",
env={"StringArray": ("../exasol-bucketfs-utils-python")})
@nox.session(name="push-pages-current", python=False)
def push_pages_current(session: nox.Session):
"""
Generate the GitHub pages documentation for the current branch and
pushes it to the remote branch github-pages/<current_branch>
"""
branch = session.run("git", "branch", "--show-current", silent=True)
with session.chdir(ROOT):
session.run("sgpg",
"--target_branch", "github-pages/" + branch[:-1],
"--push_origin", "origin",
"--push_enabled", "push",
"--module_path", "${StringArray[@]}",
env={"StringArray": ("../exasol-bucketfs-utils-python")})
@nox.session(name="push-pages-release", python=False)
def push_pages_release(session: nox.Session):
"""Generate the GitHub pages documentation for the release and pushes it to the remote branch github-pages/main"""
tags = session.run("git", "tag", "--sort=committerdate", silent=True)
# get the latest tag. last element in list is empty string, so choose second to last
tag = tags.split("\n")[-2]
with session.chdir(ROOT):
session.run("sgpg",
"--target_branch", "github-pages/main",
"--push_origin", "origin",
"--push_enabled", "push",
"--source_branch", tag,
"--source_origin", "tags",
"--module_path", "${StringArray[@]}",
env={"StringArray": ("../exasol-bucketfs-utils-python")})
@nox.session(name="run-tests", python=False)
def run_tests(session: nox.Session):
"""Run the tests in the poetry environment"""
with session.chdir(ROOT):
session.run("pytest", "tests")