-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathubuild.py
68 lines (51 loc) · 1.78 KB
/
ubuild.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
import os
import shutil
import subprocess
from uranium import current_build, task_requires
current_build.packages.install("uranium-plus[vscode]")
import uranium_plus
current_build.config.update(
{
"uranium-plus": {
"module": "tycho",
"publish": {"additional_args": ["--release"]},
"test": {
"packages": ["pytest-aiohttp", "pytest-xdist", "gunicorn", "asynctest"]
},
}
}
)
uranium_plus.bootstrap(current_build)
@current_build.task
def build_statics(build):
build.executables.run(["npm", "install", build.root])
build.executables.run(["gulp", "build"])
# current_build.tasks.append("main", "build_statics")
@current_build.task
def start_db(build):
stop_db(build)
build.executables.run(
["/bin/bash", "-c", ("docker run -p 27017:27017 --name tycho-db" " -d mongo"),]
)
@current_build.task
def stop_db(build):
# using subprocess.call as we don't want to
# error out if the container is not running.
subprocess.call(["/bin/bash", "-c", "docker stop tycho-db"])
subprocess.call(["/bin/bash", "-c", "docker rm tycho-db"])
current_build.tasks.prepend("test", "start_db")
current_build.tasks.append("test", "stop_db")
@current_build.task
@task_requires("build_docs")
def copy_docs(build):
""" copy documentation into the application directory. This allows
the docs to be packaged with the app itself.
"""
doc_dir = os.path.join(build.root, build.config["uranium-plus"]["module"], "docs")
if os.path.exists(doc_dir):
shutil.rmtree(doc_dir)
shutil.copytree(
os.path.join(build.sandbox_root, "build", "docs"),
os.path.join(build.root, build.config["uranium-plus"]["module"], "docs"),
)
current_build.tasks.append("main", "copy_docs")