This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
fabfile.py
63 lines (45 loc) · 1.7 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
59
60
61
62
63
from fabric.api import * # noqa
from fabric.colors import * # noqa
env.colorize_errors = True
env.hosts = ['sanaprotocolbuilder.me']
env.user = 'root'
env.virtualenv = 'source /usr/local/bin/virtualenvwrapper.sh'
env.project_root = '/opt/sana.protocol_builder/'
env.backend_dir = 'src-django'
env.frontend_dir = 'src-backbone'
def test():
with lcd(env.backend_dir):
local('python manage.py migrate --noinput')
local('python manage.py test api --noinput')
local('python manage.py test authentication --noinput')
with lcd(env.frontend_dir):
local('npm test')
def lint():
with lcd(env.backend_dir):
local('flake8')
def verify():
lint()
test()
def update_host():
with cd(env.project_root), prefix(env.virtualenv), prefix('workon sana_protocol_builder'):
print(green('Pulling latest revision...'))
run('git checkout master')
run('git reset --hard HEAD')
run('git pull origin master')
run('git clean -fd')
with cd(env.project_root + env.backend_dir):
print(green('Installing python dependencies...'))
run('pip install --quiet --requirement requirements.txt')
print(green('Creating database tables...'))
run('python manage.py migrate --noinput')
print(green('Restarting gunicorn...'))
run('supervisorctl restart gunicorn')
with cd(env.project_root + env.frontend_dir):
print(green('Building Backbone application...'))
run('npm install')
run('gulp build')
def travis_deploy():
update_host()
def local_deploy():
local('git push origin master')
update_host()