Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 111 lines (76 sloc) 2.487 kb
5458a3b Paul Osman Very basic fabfile
paulosman authored
1 import os
2
6af0100 Alfredo Aguirre Fabric alias for runnint the test suit. Make sure manage.py respects the...
alfredo authored
3 from fabric.api import cd, env, run, local
3f26035 Paul Osman Update fabfile to compress assets and restart apache as part of deploy
paulosman authored
4 from fabric.operations import sudo
3bf737c Alfredo Aguirre Edit Submission amended to consider the SubmissionParent. Added active f...
alfredo authored
5 from fabric.colors import yellow
5458a3b Paul Osman Very basic fabfile
paulosman authored
6
007275b Alfredo Aguirre Updated Read me and fabric commands.
alfredo authored
7 from fabric.context_managers import lcd
8
9 PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
10
11 path = lambda *a: os.path.join(PROJECT_ROOT, *a)
12
13
fe30568 Ross Bruniges fabric script has a better change of working now
rossbruniges authored
14 env.proj_root = '/var/webapps/mozilla-ignite/'
c92788f Ross Bruniges OK, NOW it has a better chance of working
rossbruniges authored
15 git_repo = 'https://github.com/rossbruniges/mozilla-ignite.org.git'
5458a3b Paul Osman Very basic fabfile
paulosman authored
16
17
3f26035 Paul Osman Update fabfile to compress assets and restart apache as part of deploy
paulosman authored
18 def run_manage_cmd(cmd):
19 """Run a manage.py command."""
20 with cd(env.proj_root):
1464e19 Alfredo Aguirre Added java support for minifying the assets
alfredo authored
21 run('python manage.py %s' % cmd)
3f26035 Paul Osman Update fabfile to compress assets and restart apache as part of deploy
paulosman authored
22
23
b7dc076 Paul Osman Add celeryd restarting to fabfile
paulosman authored
24 def restart_celeryd():
25 sudo('/etc/init.d/celeryd restart')
26
27
3f26035 Paul Osman Update fabfile to compress assets and restart apache as part of deploy
paulosman authored
28 def restart_apache():
29 sudo('/etc/init.d/apache2 restart')
30
31
5458a3b Paul Osman Very basic fabfile
paulosman authored
32 def clone():
33 """Create project directory and clone repository."""
34 with cd(os.path.dirname(env.proj_root.rstrip('/'))):
35 run('git clone --recursive %s' % (git_repo,))
36
37
b3391bf Paul Osman Update fabfile to take branch as an argument
paulosman authored
38 def update(branch):
5458a3b Paul Osman Very basic fabfile
paulosman authored
39 """Update project source."""
40 with cd(env.proj_root):
b3391bf Paul Osman Update fabfile to take branch as an argument
paulosman authored
41 run('git pull origin %s' % (branch,))
5458a3b Paul Osman Very basic fabfile
paulosman authored
42
43
921005d Paul Osman Add support for switching branchs to fabfile
paulosman authored
44 def syncdb():
45 """Run syncdb."""
46 run_manage_cmd('syncdb')
47
48
5458a3b Paul Osman Very basic fabfile
paulosman authored
49 def migrate():
50 """Run database migrations."""
7ec4b28 Paul Osman now that we're using south...
paulosman authored
51 run_manage_cmd('migrate')
3f26035 Paul Osman Update fabfile to compress assets and restart apache as part of deploy
paulosman authored
52
53
54 def compress():
55 """Compress CSS / Javascript."""
56 run_manage_cmd('compress_assets')
5458a3b Paul Osman Very basic fabfile
paulosman authored
57
58
e3328ab Paul Osman Small tweaks to fabfile
paulosman authored
59 def new_branch(branch):
60 """Checkout a new branch"""
921005d Paul Osman Add support for switching branchs to fabfile
paulosman authored
61 with cd(env.proj_root):
e3328ab Paul Osman Small tweaks to fabfile
paulosman authored
62 run('git checkout -b %s origin/%s' % (branch, branch))
63 update(branch)
921005d Paul Osman Add support for switching branchs to fabfile
paulosman authored
64 syncdb()
65 migrate()
66 compress()
67 restart_apache()
b7dc076 Paul Osman Add celeryd restarting to fabfile
paulosman authored
68 restart_celeryd()
921005d Paul Osman Add support for switching branchs to fabfile
paulosman authored
69
70
70b94fc Paul Osman Add submodule commands to deploy
paulosman authored
71 def submodules():
72 with cd(env.proj_root):
73 run('git submodule init')
74 run('git submodule sync')
75 run('git submodule update')
76
007275b Alfredo Aguirre Updated Read me and fabric commands.
alfredo authored
77 def deploy(branch):
78 """Deploy latest code from ``branch``."""
79 update(branch)
80 syncdb()
81 migrate()
82 compress()
83 submodules()
84 restart_apache()
85 restart_celeryd()
86
87
88 # Local environment
89
3bf737c Alfredo Aguirre Edit Submission amended to consider the SubmissionParent. Added active f...
alfredo authored
90 def test(*args):
91 """Run the tests locally takes a list of apps to test as arguments"""
92 if args:
93 apps = ' '.join(args)
94 else:
fae1018 Alfredo Aguirre Amended docs. Removed key hardcoded in the settings file
alfredo authored
95 apps = '' # 'challenges timeslot webcast awards activity badges events users'
3bf737c Alfredo Aguirre Edit Submission amended to consider the SubmissionParent. Added active f...
alfredo authored
96 print yellow('Testing: %s' % apps)
fae84a5 Alfredo Aguirre Ask for help implemented
alfredo authored
97 local('python manage_test.py test %s --settings=settings_test' % apps)
6af0100 Alfredo Aguirre Fabric alias for runnint the test suit. Make sure manage.py respects the...
alfredo authored
98
70b94fc Paul Osman Add submodule commands to deploy
paulosman authored
99
007275b Alfredo Aguirre Updated Read me and fabric commands.
alfredo authored
100 def syncdb_local():
101 """Syncronizes the local database"""
102 print yellow('Syncing the database')
103 with lcd(PROJECT_ROOT):
104 local('python manage.py syncdb --noinput')
105 local('python manage.py migrate --noinput')
1464e19 Alfredo Aguirre Added java support for minifying the assets
alfredo authored
106
107
007275b Alfredo Aguirre Updated Read me and fabric commands.
alfredo authored
108 def update_local():
109 """Steps to update the local application"""
110 syncdb_local()
Something went wrong with that request. Please try again.