-
Notifications
You must be signed in to change notification settings - Fork 0
/
dodo.py
86 lines (71 loc) · 1.73 KB
/
dodo.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
from pathlib import Path
from doit.task import Task
from doit.tools import create_folder
PACKAGE = "glyphsynth"
BADGES_PATH = Path("badges")
PYTEST_BADGE = BADGES_PATH / "tests.svg"
COV_BADGE = BADGES_PATH / "cov.svg"
OUT_PATH = Path("__out__")
TESTS_PATH = OUT_PATH / "tests"
JUNIT_PATH = TESTS_PATH / "junit.xml"
COV_PATH = TESTS_PATH / "cov"
COV_HTML_PATH = COV_PATH / "html"
COV_XML_PATH = COV_PATH / "coverage.xml"
def task_pytest():
"""
Run pytest and generate coverage reports.
"""
args = [
"pytest",
f"--cov={PACKAGE}",
f"--cov-report=html:{COV_HTML_PATH}",
f"--cov-report=xml:{COV_XML_PATH}",
f"--junitxml={JUNIT_PATH}",
]
return Task(
"pytest",
actions=[
(create_folder, [COV_PATH]),
# run pytest
" ".join(args),
],
targets=[
f"{COV_HTML_PATH}/index.html",
COV_XML_PATH,
JUNIT_PATH,
],
file_dep=[],
clean=True,
)
def task_badges():
"""
Generate badges from coverage results.
"""
gen_tests = [
"genbadge",
"tests",
f"-i {JUNIT_PATH}",
f"-o {PYTEST_BADGE}",
]
gen_cov = [
"genbadge",
"coverage",
f"-i {COV_XML_PATH}",
f"-o {COV_BADGE}",
]
return Task(
"badges",
actions=[
(create_folder, [BADGES_PATH]),
" ".join(gen_tests),
" ".join(gen_cov),
],
targets=[
PYTEST_BADGE,
COV_BADGE,
],
file_dep=[
JUNIT_PATH,
COV_XML_PATH,
],
)