-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfabfile.py
58 lines (46 loc) · 1.31 KB
/
fabfile.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
# type: ignore
# pylint: skip-file
"""
Application development tasks
"""
from pathlib import Path
from fabric import Connection
from invoke import Context, task
@task
def develop(context):
"""
Set up a development environment
"""
context.run("[ -d env ] || python3 -m venv env", replace_env=False)
context.run("./env/bin/pip install -U pip", replace_env=False)
context.run("./env/bin/pip install -e .[test,dev]", replace_env=False)
context.run("[ -f .env ] || cp .env.template .env")
@task
def run_dev_containers(context, reset=True):
"""
Run a set of containers which are useful for development
"""
try:
context.run("docker-compose up", pty=True, replace_env=False)
finally:
if reset:
context.run("docker-compose down", pty=True, replace_env=False)
@task
def test(context):
context.run("./env/bin/pytest", pty=True, replace_env=False)
@task
def doc(context):
context.run("./env/bin/sphinx-apidoc -o doc-src/api -f pgflux")
context.run(
"./env/bin/sphinx-build -a doc-src/ docs", pty=True, replace_env=False
)
@task
def autodoc(context):
"""
Monitor for changes and re-build docs
"""
context.run(
"git ls-files doc-src pgflux | entr -c sh -c 'fab doc'",
replace_env=False,
pty=False,
)