-
Notifications
You must be signed in to change notification settings - Fork 1
/
poetry_scripts.py
96 lines (70 loc) · 2.35 KB
/
poetry_scripts.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
import os
import shutil
import subprocess
import sys
from pathlib import Path
def check_exit_code(command):
process = subprocess.Popen(
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
while True:
output = process.stdout.readline()
if output == b"" and process.poll() is not None:
break
if output:
print(str(output.strip(), "utf-8"))
exit_code = process.poll()
if exit_code != 0:
sys.exit(exit_code)
def run_tests():
check_exit_code("docker rm -f fishjam")
check_exit_code("docker compose -f docker-compose-test.yaml pull")
check_exit_code(
"docker compose -f docker-compose-test.yaml up --remove-orphans test \
--exit-code-from test"
)
check_exit_code("docker compose -f docker-compose-test.yaml down")
def run_examples():
print("Start examples")
examples = os.listdir("./examples")
for example in examples:
check_exit_code(f"python ./examples/{example}")
print(f"After example from file: {example}")
print("All examples run without errors")
def run_local_test():
check_exit_code('poetry run pytest -m "not file_component_sources"')
def run_formatter():
check_exit_code("ruff format .")
def run_format_check():
check_exit_code("ruff format . --check")
def run_linter():
check_exit_code("ruff check .")
def run_linter_fix():
check_exit_code("ruff check . --fix")
def generate_docs():
check_exit_code(
"pdoc \
--include-undocumented \
--favicon https://logo.swmansion.com/membrane/\?width\=100\&variant\=signetDark\
--logo https://logo.swmansion.com/membrane/\?width\=70\&variant\=signetDark\
-t templates/doc \
-o doc \
fishjam"
)
here = Path(__file__).parent
input = here / "doc"
out = here / "docs" / "api"
if out.exists():
shutil.rmtree(out)
shutil.copytree(input, out)
# ...and rename the .html files to .md so that mkdocs picks them up!
for f in out.glob("**/*.html"):
f.rename(f.with_suffix(".md"))
def update_client():
check_exit_code(
"openapi-python-client update\
--url https://raw.githubusercontent.com/fishjam-dev/"
"fishjam/main/openapi.yaml \
--config openapi-python-client-config.yaml \
--custom-template-path=templates/openapi"
)