-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
80 lines (56 loc) · 1.9 KB
/
build.py
File metadata and controls
80 lines (56 loc) · 1.9 KB
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
import subprocess
import sys
import os
code_files = "unit_tests regression_tests integ_tests ./app.py"
def update_pip():
call("pip install --upgrade pip")
def install_requirements_runtime():
call("pip install -r requirements.txt")
def install_requirements_dev():
call("pip install -r requirements-dev.txt")
def depends(*trgs):
def run():
for target in trgs:
execute_target(target)
return run
def call(command):
cmd = get_flag("PYTHON_HOME") + command
subprocess.check_call(cmd, shell=True)
def execute_target(target):
targets[target]()
def flake():
call("flake8 " + code_files)
def lint():
call("pylint " + code_files +
" --disable=no-member --disable=too-many-locals --ignore-imports=yes")
def run_test(test_dir, tag):
def run():
test_cmd = "pytest app.py "
posttest_cmd = []
if get_flag("COVERAGE") == "codecov":
posttest_cmd.append("codecov -f coverage.xml -F " + tag)
test_cmd += " --cov-report xml --cov=app "
elif get_flag("COVERAGE") == "junit":
test_cmd += " --junitxml results.xml "
call(test_cmd + " -s " + test_dir)
for command in posttest_cmd:
call(command)
return run
def get_flag(flag):
return os.environ.get("BUILD_FLAG_" + flag, "")
targets = {
"updatepip": update_pip,
"reqs-dev": install_requirements_dev,
"reqs-run": install_requirements_runtime,
"reqs": depends("updatepip", "reqs-dev", "reqs-run"),
"flake": flake,
"lint": lint,
"quality": depends("flake", "lint"),
"test_unit": run_test("unit_tests", "unittests"),
"test_reg": run_test("regression_tests", "regresiontests"),
"test_integ": run_test("integ_tests", "integrationtests"),
"test": depends("test_unit", "test_reg", "test_integ")
}
if __name__ == "__main__":
for arg in sys.argv[1:]:
execute_target(arg)