forked from noirbizarre/flask-fs
-
Notifications
You must be signed in to change notification settings - Fork 3
/
tasks.py
93 lines (69 loc) · 1.87 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
from invoke import run, task
from os.path import join, abspath, dirname
ROOT = abspath(join(dirname(__file__)))
def compose(ctx, cmd):
"""Run a docker-compose command"""
return ctx.run("docker-compose {0}".format(cmd), pty=True)
@task
def clean(ctx, docs=False, bytecode=False, extra=""):
"""Cleanup all build artifacts"""
patterns = [
"build",
"dist",
"cover",
"docs/_build",
"**/*.pyc",
"*.egg-info",
".tox",
]
for pattern in patterns:
print("Removing {0}".format(pattern))
with ctx.cd(ROOT):
ctx.run("rm -rf {0}".format(pattern))
@task
def start(ctx):
"""Start the middlewares (docker)"""
with ctx.cd(ROOT):
compose(ctx, "up -d")
compose(ctx, "ps")
@task
def stop(ctx, rm=False):
"""Stop the middlewares (docker)"""
with ctx.cd(ROOT):
compose(ctx, "stop")
if rm:
compose(ctx, "rm --force")
@task
def test(ctx):
"""Run tests suite"""
with ctx.cd(ROOT):
ctx.run("pytest", pty=True)
@task
def cover(ctx, html=False):
"""Run tests suite with coverage"""
params = "--cov-report term --cov-report html" if html else ""
with ctx.cd(ROOT):
ctx.run("pytest --cov flask_fs {0}".format(params), pty=True)
@task
def tox(ctx):
"""Run tests against Python versions"""
run("tox", pty=True)
@task
def qa(ctx):
"""Run a quality report"""
with ctx.cd(ROOT):
ctx.run("flake8 flask_fs tests")
@task
def doc(ctx):
"""Build the documentation"""
with ctx.cd(ROOT):
ctx.run("cd docs && make html", pty=True)
@task
def dist(ctx):
"""Package for distribution"""
with ctx.cd(ROOT):
ctx.run("python setup.py sdist bdist_wheel", pty=True)
@task(start, tox, doc, qa, dist, default=True)
def all(ctx):
"""Run tests, reports and packaging"""
pass