-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
93 lines (69 loc) · 2.3 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
89
90
91
92
93
import glob
import os
import sys
from pathlib import Path
from invoke import call, task
@task
def isort(c):
root_path = Path(os.path.dirname(os.path.abspath(__file__)))
with c.cd(str(root_path)):
c.run("isort automate test")
@task(isort)
def black(c):
"Runs black code formatter"
root_path = Path(os.path.dirname(os.path.abspath(__file__)))
with c.cd(str(root_path)):
c.run("black --target-version py36 -l 80 automate test")
@task
def mypy(c):
"Run static typechecker on the code"
root_path = Path(os.path.dirname(os.path.abspath(__file__)))
with c.cd(str(root_path)):
c.run("mypy automate")
@task
def test(c, integration=False):
"Run unit tests"
root_path = Path(os.path.dirname(os.path.abspath(__file__)))
with c.cd(str(root_path)):
if integration:
c.run(
"pytest --cov automate test/unit test/integration --cov-config=pyproject.toml"
)
else:
c.run("pytest --cov automate test/unit --cov-config=pyproject.toml")
@task
def cov(c, integration=False):
"Generate html coverage report"
test(c, integration)
root_path = Path(os.path.dirname(os.path.abspath(__file__)))
with c.cd(str(root_path)):
c.run("coverage html")
c.run("xdg-open htmlcov/index.html")
@task
def monkeytype(c):
"Run unit tests and collect dynamic type information"
root_path = Path(os.path.dirname(os.path.abspath(__file__)))
with c.cd(str(root_path)):
c.run("pytest --monkeytype-output=monkeytype.sqlite3 test/unit")
@task
def pre_commit(c):
"Installs pre commit hooks"
root_path = Path(os.path.dirname(os.path.abspath(__file__)))
with c.cd(str(root_path)):
c.run("pre-commit install")
@task
def doc(c):
"Starts the documentation viewer"
root_path = Path(os.path.dirname(os.path.abspath(__file__)))
with c.cd(str(root_path)):
c.run("pydoc-markdown --server")
@task
def clean_examples(c):
"Removes autogenerated files in examples"
import glob
root_path = Path(os.path.dirname(os.path.abspath(__file__)))
glob_pattern = root_path / "examples" / "**" / "build*"
for res in glob.glob(str(glob_pattern), recursive=True):
res = Path(res)
if res.is_dir():
c.run("rm -rf {}".format(str(res)))