-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
88 lines (66 loc) · 1.86 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import json
import os
from invoke import task
CWD = os.path.abspath(os.path.dirname(__file__))
@task
def run_linters(c):
"Run linters"
cmd = "poetry run ruff check arrlio"
c.run(cmd)
@task
def tests_small(c):
"""Run small tests"""
cmd = (
"coverage run --data-file=artifacts/.coverage --source arrlio -m pytest -v --maxfail=1 tests/small/ && "
"coverage json --data-file=artifacts/.coverage -o artifacts/coverage.json && "
"coverage report --data-file=artifacts/.coverage -m"
)
c.run(cmd)
@task
def tests_medium(c):
"""Run medium tests"""
cmd = "pytest -v --maxfail=1 --timeout=300 tests/medium/test_arrlio.py"
c.run(cmd)
@task
def run_tests(c):
tests_small(c)
tests_medium(c)
@task
def run_checks(c):
run_linters(c)
tests_small(c)
tests_medium(c)
@task
def generate_coverage_gist(c):
with open("artifacts/coverage.json") as f:
data = json.load(f)
percent = int(data["totals"]["percent_covered_display"])
if percent >= 90:
color = "brightgreen"
elif percent >= 75:
color = "green"
elif percent >= 50:
color = "yellow"
else:
color = "red"
data = {
"description": "Arrlio shields.io coverage json data",
"files": {
"coverage.json": {
"content": json.dumps(
{
"schemaVersion": 1,
"label": "coverage",
"message": f"{percent}%",
"color": color,
}
)
},
},
}
with open("artifacts/shields_io_coverage_gist_data.json", "w") as f:
f.write(json.dumps(data))
@task
def pygettext(c):
cmd = f"""poetry run python {CWD}/scripts/pygettext.py -d arrlio -o {CWD}/arrlio/locales/arrlio.pot arrlio"""
c.run(cmd)