-
Notifications
You must be signed in to change notification settings - Fork 42
/
tasks.py
79 lines (57 loc) · 1.69 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
import os
import sys
import shutil
from invoke import task
def _get_wheel_file() -> str:
dist = "dist"
assert len(os.listdir(dist)) > 0, "No files found in dist folder"
wheel_file = os.path.join(dist, os.listdir(dist)[0])
return wheel_file
@task
def clean(_):
shutil.rmtree(
os.path.join("tests", "__out__"),
ignore_errors=True,
)
shutil.rmtree(".tox", ignore_errors=True)
shutil.rmtree(".pytest_cache", ignore_errors=True)
shutil.rmtree("build", ignore_errors=True)
shutil.rmtree("dist", ignore_errors=True)
shutil.rmtree("robotframework_jsonlibrary.egg-info", ignore_errors=True)
for path, _, _ in os.walk("."):
if path.endswith("__pycache__"):
shutil.rmtree(path, ignore_errors=True)
@task(clean)
def build(ctx):
ctx.run(f"{sys.executable} setup.py bdist_wheel", hide="both")
wheel_file = _get_wheel_file()
assert wheel_file.endswith(".whl")
@task
def uninstall(ctx):
ctx.run(
f"{sys.executable} -m pip uninstall robotframework-jsonlibrary -y", hide="both"
)
@task(build, uninstall)
def install(ctx):
wheel_file = _get_wheel_file()
ctx.run(f"{sys.executable} -m pip install {wheel_file}", hide="both")
@task(install)
def test(ctx):
ctx.run("tox")
@task
def style_check(ctx):
ctx.run("black . --check --diff")
@task
def reformat_code(ctx):
ctx.run("black .")
@task
def publish(ctx):
ctx.run(f"{sys.executable} -m twine upload dist/*")
@task
def docs(ctx):
ctx.run(f"{sys.executable} -m robot.libdoc JSONLibrary docs/JSONLibrary.html")
@task(install)
def lint(ctx):
ctx.run("pylint JSONLibrary --disable=R,C,W0703,W0212,W1203")
uninstall(ctx)
clean(ctx)