-
Notifications
You must be signed in to change notification settings - Fork 79
/
tasks.py
48 lines (36 loc) · 1.09 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
from invoke import task
cmd_echo = True
@task
def clean(c):
patterns = [
"__pycache__",
".coverage",
".pytest_cache",
".mypy_cache",
"*.pyc",
]
for pattern in patterns:
c.run("find . -d -name '{}' -exec rm -rf {{}} \\;".format(pattern), pty=True, echo=cmd_echo)
with c.cd("docs"):
c.run("poetry run -- make clean", pty=True, echo=cmd_echo)
@task
def lint(c):
c.run("poetry run -- mypy basana", pty=True, echo=cmd_echo)
c.run("poetry run -- flake8", pty=True, echo=cmd_echo)
@task(lint)
def test(c, html_report=False):
# Execute testcases.
cmd = "poetry run -- pytest -vv --cov --cov-config=setup.cfg --durations=10"
if html_report:
cmd += " --cov-report=html:cov_html"
c.run(cmd, pty=True, echo=cmd_echo)
@task
def create_virtualenv(c, all_extras=True):
cmd = ["poetry", "install"]
if all_extras:
cmd.append("--all-extras")
c.run(" ".join(cmd), pty=True, echo=cmd_echo)
@task
def build_docs(c):
with c.cd("docs"):
c.run("poetry run -- make html", pty=True, echo=cmd_echo)