-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtasks.py
41 lines (31 loc) · 1.08 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
"""Common project tasks."""
from invoke import task
@task
def clean(cline):
"""Clean project artifacts such as python cache."""
print("Deleting __pycache__ directories.")
cline.run("find . -iname '__pycache__' | xargs rm -rf")
@task
def style(cline, write=False):
"""Style and optionally re-write the source files."""
check_arg = "" if write else "--check"
print("Checking code style with Black.")
cline.run(f"python3 -m black {check_arg} .")
@task
def lint(cline):
"""Check for linting errors in the source code."""
print("Linting with pylint.")
cline.run(r"git ls-files '*.py' | xargs python3 -m pylint -j 0")
print("Type checking with mypy.")
cline.run(r"git ls-files '*.py' | xargs python3 -m mypy")
@task
def test(cline):
"""Discover and run test cases."""
print("Running unit tests.")
cline.run("TF_CPP_MIN_LOG_LEVEL=3 python3 -m unittest")
@task(style, lint, test)
def build(cline):
"""Build project code."""
print("Loading summary.")
cline.run(r"git ls-files '*.py' | xargs wc -l")
print("Build complete.")