-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtasks.py
97 lines (82 loc) · 2.19 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
94
95
96
97
from pathlib import Path
from invoke import task
sub_package = "properties"
@task
def install(ctx):
"""
Install all sidekick libraries.
"""
groups = [
# Core libs
['functions', 'properties', 'proxy', 'seq'],
# Data types
['tree', 'collections', 'types'],
# Extra
['api', 'beta', 'core', 'experimental', 'extra', 'hypothesis', 'ideas']
]
for grp in groups:
for lib in grp:
ctx.run(f'cd sidekick-{lib} && python setup.py develop')
@task
def test(ctx, all=False, maxfail=None, verbose=False):
"""
Run tests.
"""
flags = []
if all:
doctest(ctx)
else:
flags.extend(["--lf", f"--maxfail={maxfail or 2}"])
if verbose:
flags.append("-vv")
flags = " ".join(flags)
return ctx.run(
f"python -c 'import sidekick.{sub_package}'"
f" && pytest tests/ --cov --cov-report=xml {flags}",
pty=True,
)
@task
def docs(ctx, clear=False, strict=False, auto=False):
"""
Build documentation.
"""
suffix = " -W" if strict else ""
if clear:
ctx.run("rm -rf build/docs/")
if auto:
ctx.run("sphinx-autobuild docs/ build/docs/ -n" + suffix, pty=True)
else:
ctx.run("sphinx-build docs/ build/docs/ -n" + suffix, pty=True)
@task
def doctest(ctx):
"""
Run sphinx doc tests.
"""
ctx.run("pytest tests/ --doctest-modules sidekick/ --doctest-plus", pty=True)
ctx.run("rm -rf docs/_build/")
ctx.run("cd docs && make doctest", pty=True)
@task
def check_style(ctx):
"""
Check code style issues.
"""
ctx.run("black . --check")
ctx.run("flake8 sidekick/")
ctx.run("mypy sidekick/")
@task
def ci(ctx, dry_run=False):
"""
Full pipeline performed by CI runner.
"""
conf = Path('.github/workflows/pythonpackage.yml').read_text()
_, _, src = conf.partition('Run CI')
_, _, src = src.partition('|')
src, _, _ = src.partition('- name: ')
cmds = [ln[8:] for ln in src.splitlines() if ln.strip()]
if dry_run:
print("Dry run:")
print('\n'.join(cmds))
return
print("Running commands:")
for cmd in cmds:
ctx.run(cmd, pty=True)