-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtasks.py
More file actions
67 lines (53 loc) · 2.09 KB
/
Copy pathtasks.py
File metadata and controls
67 lines (53 loc) · 2.09 KB
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
"""Tasks for use with Invoke.
(c) 2022 Network To Code
"""
import yaml
from pathlib import Path
from invoke import task
@task
def update_docs(context, local=False):
"""Run helm-docs to update README.md and reference.md.
Mimics the Update Docs CI job without committing. By default runs
via Docker from development/; set local=True to run helm-docs
locally (must be installed).
"""
if not local:
print("Running helm-docs via Docker...")
context.run(
"docker compose -f development/docker-compose.yml run --build --rm update-docs",
pty=True,
)
else:
print("Running helm-docs locally...")
context.run("helm-docs --chart-search-root=charts --template-files=README.md.gotmpl")
context.run(
"helm-docs --chart-to-generate=charts/nautobot "
"--template-files=./docs/configuration/reference.md.gotmpl "
"--output-file=../../docs/configuration/reference.md"
)
print("Docs updated.")
@task
def docs(context, strict=False):
"""Build and serve docs locally for development."""
command = "poetry run mkdocs serve --verbose"
if strict:
command = f"{command} --strict"
print("Serving Documentation...")
context.run(command)
@task
def check_release_tag(context, tag):
"""Check that the provided tag matches the value in Chart.yaml."""
print(f"Checking that provided tag '{tag}' matches Chart.yaml version.")
if tag.startswith("v"):
tag = tag[1:]
print(f"Stripped leading 'v' from tag. New tag is '{tag}'.")
print("Loading Chart.yaml.")
chart_yaml_path = Path("charts/nautobot/Chart.yaml")
with open(chart_yaml_path, "r", encoding="utf-8") as chart_file:
chart_yaml_data = yaml.safe_load(chart_file)
version = chart_yaml_data.get("version")
print(f"Found version '{version}' in Chart.yaml.")
if tag != version:
print(f"ERROR: Provided tag '{tag}' does not match Chart.yaml version '{version}'.")
exit(1)
print(f"Provided tag '{tag}' matches Chart.yaml version '{version}'.")