-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtasks.py
67 lines (48 loc) · 1.6 KB
/
tasks.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 sys
from pathlib import Path
from invoke import task, Context # type: ignore
CURRENT_DIRECTORY = Path(__file__).resolve()
DOCUMENTATION_DIRECTORY = CURRENT_DIRECTORY.parent / "docs"
MAIN_DIRECTORY_PATH = Path(__file__).parent
@task
def format(context: Context) -> None:
"""Run RUFF to format all Python files."""
exec_cmds = ["ruff format .", "ruff check . --fix"]
with context.cd(MAIN_DIRECTORY_PATH):
for cmd in exec_cmds:
context.run(cmd)
@task
def lint_yaml(context: Context) -> None:
"""Run Linter to check all Python files."""
print(" - Check code with yamllint")
exec_cmd = "yamllint ."
with context.cd(MAIN_DIRECTORY_PATH):
context.run(exec_cmd)
@task
def lint_mypy(context: Context) -> None:
"""Run Linter to check all Python files."""
print(" - Check code with mypy")
exec_cmd = "mypy --show-error-codes ."
with context.cd(MAIN_DIRECTORY_PATH):
context.run(exec_cmd)
@task
def lint_ruff(context: Context) -> None:
"""Run Linter to check all Python files."""
print(" - Check code with ruff")
exec_cmd = "ruff check ."
with context.cd(MAIN_DIRECTORY_PATH):
context.run(exec_cmd)
@task(name="lint")
def lint_all(context: Context) -> None:
"""Run all linters."""
lint_yaml(context)
lint_ruff(context)
# lint_mypy(context)
@task(name="docs")
def docs_build(context: Context) -> None:
"""Build documentation website."""
exec_cmd = "npm run build"
with context.cd(DOCUMENTATION_DIRECTORY):
output = context.run(exec_cmd)
if output.exited != 0:
sys.exit(-1)