forked from qentinelqi/qweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathduties.py
101 lines (86 loc) · 2.86 KB
/
duties.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
98
99
100
101
"""Run dev tasks locally"""
import sys
from platform import system
from duty import duty
python_exe = sys.executable
@duty
def typing(ctx, path="QWeb"):
"""
Check code typing
Arguments:
ctx: The context instance (passed automatically)
path: path of folder/file to check
"""
ctx.run(f"{python_exe} -m mypy --show-error-codes {path}", title="Checking code typing", capture=False)
@duty
def lint(ctx, path="QWeb"):
"""
Check code quality
Arguments:
ctx: The context instance (passed automatically)
path: path of folder/file to check
"""
ctx.run(f"{python_exe} -m flake8 {path}", title="Checking code quality: flake8", capture=False)
ctx.run(f"{python_exe} -m pylint {path}", title="Checking code quality: pylint", capture=False)
@duty
def unit_tests(ctx):
"""
Runs unit tests
Args:
ctx: The context instance (passed automatically)
"""
ctx.run([f"{python_exe}", "-m", "pytest", "-v", "--junit-xml", "unittests.xml","--cov", "QWeb"], title="Unit tests", capture=False)
@duty
def acceptance_tests(ctx,
browser="chrome",
exitonfailure="True"):
"""
Runs robot Acceptance tests
Args:
ctx: The context instance (passed automatically)
browser: Browser name (use fullname instead of shorthand), [chrome, firefox, edge, safari]
Default: chrome
exitonfailure: Stop tests upon first failing test. True/False
Default: True
"""
def remove_extra_whitespaces(string: str) -> str:
return " ".join(string.split())
cmd_exit_on_failure = ""
if exitonfailure.lower() == "true":
cmd_exit_on_failure = "--exitonfailure"
os = system().upper()
if os == "DARWIN":
os = "MACOS"
excludes = [
f"PROBLEM_IN_{os}",
f"PROBLEM_IN_{browser.upper()}",
"FLASK",
"RESOLUTION_DEPENDENCY",
"jailed",
"WITH_DEBUGFILE"
]
cmd_excludes = f'-e {" -e ".join(excludes)}'
cmd_str = remove_extra_whitespaces(
f" {python_exe} -m robot"
f" {cmd_exit_on_failure}"
f" -v BROWSER:{browser}"
f" {cmd_excludes}"
f" test/Acceptance"
)
ctx.run(cmd_str, title="Acceptance tests", capture=False)
@duty
def kw_docs(ctx):
"""
Generates updated keyword docs
Args:
ctx: The context instance (passed automatically)
"""
ctx.run([f"{python_exe}", "-m", "robot.libdoc", "-F", "REST", "QWeb", "./docs/QWeb.html"], title="Generating keyword documentation")
@duty
def create_dist(ctx):
"""
Creates distribution packages
Args:
ctx: The context instance (passed automatically)
"""
ctx.run(f"{python_exe} setup.py sdist bdist_wheel", title="Creating packages to ./dist", capture=False)