-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathtasks.py
78 lines (62 loc) · 1.74 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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
from invoke import Collection, task, run
# The 'pty' setting is nice, as it provides colour output, but it doesn't work
# on Windows.
USE_PTY = os.name != "nt"
@task(
name="python",
help={
"testargs": "Arguments to pass to the test suite (default: '')",
"keep": "Do not remove the test container after running",
},
)
def test_python(ctx, testargs="", keep=False):
"""Run lando-ui python tests."""
ctx.config.keep_containers = keep # Stashed for our cleanup tasks
run(
"docker-compose run {rm} lando-ui pytest {args}"
"".format(args=testargs, rm=("" if keep else " --rm")),
pty=USE_PTY,
echo=True,
)
@task(name="flake8")
def lint_flake8(ctx):
"""Run flake8."""
run("docker-compose run --rm py3-linter flake8 .", pty=USE_PTY, echo=True)
@task(name="black")
def lint_black(ctx):
"""Run black."""
run(
f"docker-compose run --rm py3-linter black --diff .", # noqa
pty=USE_PTY,
echo=True,
)
@task(default=True, name="all", post=[lint_flake8, lint_black])
def lint_all(ctx):
pass
@task(default=True, name="all")
def format_all(ctx):
run("docker-compose run --rm py3-linter black", echo=True)
@task(default=True, name="all", post=[test_python])
def test_all(ctx):
pass
namespace = Collection(
Collection(
"test",
test_python,
test_all,
),
Collection(
"lint",
lint_all,
lint_flake8,
lint_black,
),
Collection(
"format",
format_all,
),
)