-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfabfile.py
More file actions
153 lines (123 loc) · 4.74 KB
/
fabfile.py
File metadata and controls
153 lines (123 loc) · 4.74 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
from datetime import date
import git
from fabric.api import lcd, local, warn_only, cd, run, env
from fabenv import version_file, INTERNAL_APPS
from fabconfig import hosts, password
env.hosts = hosts
env.password = password
def local_deploy():
# pulls new content and deploys it
local('git pull')
local('python2.7 manage.py collectstatic --noinput')
local('python2.7 manage.py migrate')
def deploy():
with cd('/home/mc706/webapps/taskburn/taskburn'):
run('git pull')
run('python2.7 manage.py collectstatic --noinput')
run('python2.7 manage.py migrate')
# local('python2.7 manage.py test --noinput') #no tests written yet
with warn_only():
with cd('/home/mc706/webapps/taskburn/apache2/'):
run('bin/restart')
def update_change_log(version, new):
try:
g = git.Git('./')
log = g.log('%s..' % version, '--no-merges', '--pretty=format:%s').split('\n')
today = date.today()
with open('CHANGELOG.md', 'r') as old_changelog:
old = old_changelog.read()
minus_header = "\n".join(old.split('\n')[1:])
with open('CHANGELOG.md', 'w') as new_changelog:
new_changelog.write('#CHANGELOG\n\n')
new_changelog.write('##Version %s (%s)\n\n' % (new, today))
for line in log:
new_changelog.write("* " + line + "\n")
new_changelog.write('\n')
new_changelog.write(minus_header)
except Exception as ex:
print ex
def bump_patch():
with open(version_file, 'r') as f:
original = f.read()
version = original.split('=')[1].strip('\" \n\'')
major, minor, patch = version.split('.')
patch = int(patch) + 1
new_version = '%s.%s.%s' % (major, minor, patch)
update_change_log(version, new_version)
with open(version_file, 'w') as f:
f.write('__version__ = "%s.%s.%s"' % (major, minor, patch))
local('git add %s' % version_file)
local('git add CHANGELOG.md')
local('git commit -m "updated version to %s.%s.%s"' % (major, minor, patch))
local('git tag %s.%s.%s -m "Update for release"' % (major, minor, patch))
def bump_minor():
with open(version_file, 'r') as f:
original = f.read()
version = original.split('=')[1].strip('\" \n\'')
major, minor, patch = version.split('.')
patch = 0
minor = int(minor) + 1
new_version = '%s.%s.%s' % (major, minor, patch)
update_change_log(version, new_version)
with open(version_file, 'w') as f:
f.write('__version__ = "%s.%s.%s"' % (major, minor, patch))
local('git add %s' % version_file)
local('git add CHANGELOG.md')
local('git commit -m "updated version to %s.%s.%s"' % (major, minor, patch))
local('git tag %s.%s.%s -m "Update for release"' % (major, minor, patch))
def bump_major():
with open(version_file, 'r') as f:
original = f.read()
version = original.split('=')[1].strip('\" \n\'')
major, minor, patch = version.split('.')
patch = 0
minor = 0
major = int(major) + 1
new_version = '%s.%s.%s' % (major, minor, patch)
update_change_log(version, new_version)
with open(version_file, 'w') as f:
f.write('__version__ = "%s.%s.%s"' % (major, minor, patch))
local('git add %s' % version_file)
local('git add CHANGELOG.md')
local('git commit -m "updated version to %s.%s.%s"' % (major, minor, patch))
local('git tag %s.%s.%s -m "Update for release"' % (major, minor, patch))
def cut(release='patch'):
test()
if release == 'patch':
bump_patch()
elif release == 'minor':
bump_minor()
elif release == 'major':
bump_major()
elif release == 'none':
pass
local('git push --follow-tags')
def freeze():
local('pip freeze > requirements.txt')
def release():
with open(version_file, 'r') as f:
original = f.read()
version = original.split('=')[1].strip('\" \n\'')
local('git flow release start %s' % version)
local('git flow release finish %s -Fpn' % version)
def quality_check():
local('pep8 .')
local('jshint assets')
local('xenon . -a A -m A -b A -i core')
local('prospector')
def test():
app_list = " ".join(INTERNAL_APPS)
local('coverage run manage.py test %s' % app_list)
local('coverage report --fail-under=100')
quality_check()
def prepare_assets():
local('npm install')
local("bower install")
compile_scss()
local('python manage.py collectstatic --no-input')
def compile_scss():
with lcd('assets/lib/styles'):
local('python -mscss styles.scss > styles.css')
def bootstrap():
"""Sets up certain environment commands"""
local('git config commit.template templates/git-commit-template.txt')