-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtasks.py
104 lines (76 loc) · 2.18 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
98
99
100
101
102
103
104
from invoke import task
from pathlib import Path
import os
import os.path
import shutil
import glob
CHANGELOG = "CHANGELOG"
filters = ["poc", "new release", "wip", "cleanup", "!nocl"]
def filter_entries(filename):
buffer = []
with open(filename) as old_file:
buffer = old_file.read().split("\n")
with open(filename, "w") as new_file:
for line in buffer:
if not any(bad_word in line.lower() for bad_word in filters):
new_file.write(line + "\n")
assert Path.cwd() == Path(__file__).parent
@task
def robot(ctx):
ctx.run("robot -A atest/run_tests.robot")
@task
def unit(ctx):
ctx.run("nosetests tests")
@task
def lint(ctx):
ctx.run("flake8")
@task
def docs(ctx):
ctx.run("python -m robot.libdoc --pythonpath src SeleniumProxy docs/keywords.html")
ctx.run("cp docs/keywords.html docs/index.html")
@task
def compileDev(ctx):
ctx.run("pip-compile --output-file=requirements-dev.txt dependencies/requirements-dev.in")
@task
def compileProd(ctx):
ctx.run("pip-compile --output-file=requirements.txt dependencies/requirements.in")
@task
def clean(ctx):
to_be_removed = [
"reports/",
"__pycache__/",
"src/robotframework_seleniumproxy.egg-info/",
"dist/",
"*.html",
"selenium-screenshot-*.png",
"geckodriver.log",
"SeleniumProxy.log",
]
for item in to_be_removed:
if os.path.isdir(item):
shutil.rmtree(item)
elif os.path.isfile(item):
os.remove(item)
else:
for filename in glob.glob(item):
os.remove(filename)
@task
def build(ctx):
ctx.run("python setup.py sdist")
@task
def changelog(ctx, version=None):
if version is not None:
version = "-c {}".format(version)
else:
version = ""
ctx.run("gcg -x -o {} -O rpm {}".format(CHANGELOG, version))
filter_entries(CHANGELOG)
@task
def release(ctx, version=None):
assert version != None
changelog(ctx, version)
docs(ctx)
ctx.run("git add docs/* {}".format(CHANGELOG))
ctx.run("git commit -m 'New Release {}'".format(version))
ctx.run("git tag {}".format(version))
build(ctx)