-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile
executable file
·93 lines (72 loc) · 1.54 KB
/
Taskfile
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
#!/bin/bash
src='.'
function cmd {
# Run any command you want
poetry run "${@}"
}
function fmt {
cmd ruff format . "${@}"
cmd ruff check --fix . "${@}"
fmt-xml
}
function fmt-check {
echo "Checking the format with ruff..."
cmd ruff format --check ${src}
}
function fmt-xml {
echo "Formatting xml files using xmllint..."
cmd pre-commit run format-xmllint --files $(git ls-files -- '*.xml')
}
function lint-only {
echo "Linting using ruff..."
cmd ruff check ${src}
}
function install {
echo "Installing dependencies..."
poetry install
echo "Installing pre-commit hooks..."
cmd pre-commit install
}
function type-check {
echo "Type checking using mypy..."
cmd mypy
}
function lint {
fmt-check
lint-only
type-check
}
function test {
lint
output=$(validate 2>&1) # Execute the command and capture the output – stderr will go to stdout.
if echo "$output" | grep -q "Some files are not"; then
echo "$output"
exit 1
fi
echo "Running tests using pytest..."
cmd pytest -n 4 "${@}"
}
function test-only {
cmd pytest -n 4 "${@}"
}
function compile {
validate
cmd python utils/schema/compile.py
}
function build-docs {
cmd mkdocs build
}
function serve-docs {
cmd mkdocs serve
}
function validate {
echo "Checking the xml sources..."
cmd python utils/schema/validate.py
}
function help {
echo "$0 <task> <args>"
echo "Tasks:"
compgen -A function | cat -n
}
TIMEFORMAT="Task completed in %3lR"
time ${@:-default}