Added: Fabric task to deploy current project to remote host #1337

Closed
coffeedogs wants to merge 1 commits from fab_deploy into v0.6
2 changed files with 51 additions and 5 deletions

View File

@ -17,7 +17,7 @@ For more help on a particular command
from fabric.api import env from fabric.api import env
from fabfile.tasks import code_quality, build_docs, push_docs, clean, test from fabfile.tasks import build_docs, clean, code_quality, configure, deploy, push_docs, test, start, stop
# Without this, `fab -l` would display the whole docstring as preamble # Without this, `fab -l` would display the whole docstring as preamble
@ -25,11 +25,15 @@ __doc__ = ""
# This list defines which tasks are made available to the user # This list defines which tasks are made available to the user
__all__ = [ __all__ = [
"code_quality",
"test",
"build_docs", "build_docs",
"push_docs",
"clean", "clean",
"code_quality",
"configure",
"deploy",
"push_docs",
"start",
"stop",
"test",
] ]
# Honour the user's ssh client configuration # Honour the user's ssh client configuration

View File

@ -315,4 +315,46 @@ def clean():
"""Clean up files generated by fabric commands.""" """Clean up files generated by fabric commands."""
with hide('running', 'stdout'): with hide('running', 'stdout'):
with cd(PROJECT_ROOT): with cd(PROJECT_ROOT):
with settings(warn_only=True):
run(r"find . -name '*.pyc' -exec rm '{}' \;") run(r"find . -name '*.pyc' -exec rm '{}' \;")
@task
def start(path):
"""
Start pybitmessage on the target host
.. todo:: automate this: xpra start :7 && DISPLAY=:7 src/bitmessagemain.py &
"""
with cd(path):
pass
@task
def stop():
"""Stop pybitmessage on the target host"""
with settings(warn_only=True):
run('pkill -9 pybitmessage; pkill xpra')
@task
def configure():
"""Prepare a host for deployment"""
sudo('apt install -y rsync xpra pyqt4-dev-tools')
@task
def deploy():
"""
Deploy current version to test host.
"""
clean()
stop()
remote_dir = os.path.join(run('pwd'), 'pybitmessage')
rsync_project(
remote_dir=remote_dir,
local_dir=os.path.join(PROJECT_ROOT, ''),
exclude=[
'.git/',
]
)
start(remote_dir)