forked from ArchipelProject/Archipel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci.py
executable file
·182 lines (146 loc) · 8.3 KB
/
ci.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/python
#
# ci.py
#
# Copyright (C) 2010 Antoine Mercadal <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os, sys, datetime, commands
CONFIGURATION="debug"
FORCE=False
BUILD_CAPPUCCINO=True
BUILD_LPKIT=True
BUILD_TNKIT=True
BUILD_VNCCAPPUCCINO=True
BUILD_STROPHECAPPUCCINO=True
BUILD_GROWLCAPPUCCINO=True
BUILD_ARCHIPELCLIENT=True
DEPLOY_PATH="/var/www/archipelproject.org/app/"
EXPORT_PATH="/var/www/archipelproject.org/nightlies/old/"
API_PATH="/var/www/archipelproject.org/api/"
def updateSubmodules():
os.system("bash ./pull.sh")
def buildCappuccino():
os.system("echo \* Starting to build Cappuccino")
if os.system("cd ./ArchipelClient/Libraries/Cappuccino && jake clobber-theme && jake release && jake debug"):
if os.system("cd ./ArchipelClient/Libraries/Cappuccino && jake clean && jake release && jake debug"):
sys.exit(-1)
def buildGrowlCappuccino():
os.system("echo \* Starting to build GrowlCappuccino")
if os.system("cd ./ArchipelClient/Libraries/GrowlCappuccino && jake release && jake debug"):
os.system("echo \* unable to build GrowlCappuccino")
sys.exit(-2)
def buildLPKit():
os.system("echo \* Starting to build LPKit")
if os.system("cd ./ArchipelClient/Libraries/LPKit && export CAPP_BUILD=./Build && export CONFIGURATION=Release && jake build && export CONFIGURATION=Debug && jake build"):
os.system("echo \* unable to build LPKit")
sys.exit(-4)
def buildStropheCappuccino():
os.system("echo \* Starting to build StropheCappuccino")
if os.system("cd ./ArchipelClient/Libraries/StropheCappuccino && jake release && jake debug"):
os.system("echo \* unable to build StropheCappuccino")
sys.exit(-6)
def buildTNKit():
os.system("echo \* Starting to build TNKit")
if os.system("cd ./ArchipelClient/Libraries/TNKit && jake release && jake debug"):
os.system("echo \* unable to build TNKit")
sys.exit(-7)
def buildVNCCappuccino():
os.system("echo \* Starting to build VNCCappuccino")
if os.system("cd ./ArchipelClient/Libraries/VNCCappuccino && jake release && jake debug"):
os.system("echo \* unable to build VNCCappuccino")
sys.exit(-8)
def buildArchipel(export_dir, build):
os.system("echo \* Starting to build Archipel")
rev = commands.getoutput("git rev-parse --short HEAD");
builddate = datetime.datetime.now().strftime("%Y%m%d%H%M")
os.system("rm -rf ./ArchipelClient/Build")
os.system("cd ./ArchipelClient && capp gen -fl --force .")
os.system("cd ./ArchipelClient && ./buildArchipel -Cau --config=%s" % CONFIGURATION)
if os.system("cd ./ArchipelClient && ./buildArchipel -bag --config=%s" % CONFIGURATION):
os.system("echo \* unable to build ArchipelClient. end of line.")
sys.exit(-9)
os.system("cp ./ArchipelClient/index-debug.html ./ArchipelClient/Build/%s/Archipel" % CONFIGURATION.capitalize())
os.system("cd ./ArchipelClient/Build/%s/ && tar -czf %s/Archipel-nightly-%s-%s-client.tar.gz ./Archipel" % (CONFIGURATION.capitalize(), export_dir, builddate, rev))
os.system("tar -czf %s/Archipel-nightly-%s-%s-agent.tar.gz ./ArchipelAgent" % (export_dir, builddate, rev))
os.system("cd %s/.. && rm -f latest-archipel-agent.tar.gz" % (export_dir))
os.system("cd %s/.. && rm -f latest-archipel-client.tar.gz" % (export_dir))
os.system("cd %s/.. && ln -s old/Archipel-nightly-%s-%s-agent.tar.gz latest-archipel-agent.tar.gz" % (export_dir, builddate, rev))
os.system("cd %s/.. && ln -s old/Archipel-nightly-%s-%s-client.tar.gz latest-archipel-client.tar.gz" % (export_dir, builddate, rev))
os.system("chown cruise:www-data %sArchipel-nightly-%s-%s-client.tar.gz" % (export_dir, builddate, rev))
os.system("chown cruise:www-data %sArchipel-nightly-%s-%s-agent.tar.gz" % (export_dir, builddate, rev))
os.system("chmod 755 %sArchipel-nightly-%s-%s-client.tar.gz" % (export_dir, builddate, rev))
os.system("chmod 755 %sArchipel-nightly-%s-%s-agent.tar.gz" % (export_dir, builddate, rev))
def deployArchipel(deploy_dir):
os.system("echo \* Starting to deploy Archipel into app.archipelproject.org")
os.system("rm -rf %s/*" % deploy_dir)
os.system("echo 'deploying new build, please reload in a moment' > %s/index.txt" % deploy_dir)
os.system("cp -a ./ArchipelClient/Build/%s/Archipel/* %s" % (CONFIGURATION.capitalize(), deploy_dir))
os.system("chown -R cruise:www-data %s/*" % deploy_dir)
os.system("chmod 755 -R %s/*" % deploy_dir)
os.system("find %s/* -exec touch {} \;" % deploy_dir)
os.system("rm -f %s/index.txt" % deploy_dir)
def generateAPI(api_dir):
os.system("echo \* Starting to generate documentation")
os.system("rm -rf %s/*" % api_dir)
os.system("echo \* Generating doc for ArchipelClient")
os.system("mkdir -p %s/archipel-client" % api_dir)
os.system("cd ArchipelClient; jake docs")
os.system("cp -a ArchipelClient/Build/Documentation/html/* %s/archipel-client/" % api_dir)
os.system("chown -R cruise:www-data %s/archipel-client/" % api_dir)
os.system("echo \* Generating doc for StropheCappuccino")
os.system("mkdir -p %s/strophecappuccino" % api_dir)
os.system("cd ./ArchipelClient/Libraries/StropheCappuccino; jake docs")
os.system("cp -a ./ArchipelClient/Libraries/StropheCappuccino/Build/Documentation/html/* %s/strophecappuccino/" % api_dir)
os.system("chown -R cruise:www-data %s/strophecappuccino/" % api_dir)
os.system("echo \* Generating doc for VNCCappuccino")
os.system("mkdir -p %s/vnccappuccino" % api_dir)
os.system("cd ./ArchipelClient/Libraries/VNCCappuccino; jake docs")
os.system("cp -a ./ArchipelClient/Libraries/VNCCappuccino/Build/Documentation/html/* %s/vnccappuccino/" % api_dir)
os.system("chown -R cruise:www-data %s/vnccappuccino/" % api_dir)
os.system("echo \* Generating doc for GrowlCappuccino")
os.system("mkdir -p %s/growlcappuccino" % api_dir)
os.system("cd ./ArchipelClient/Libraries/GrowlCappuccino; jake docs")
os.system("cp -a ./ArchipelClient/Libraries/GrowlCappuccino/Build/Documentation/html/* %s/growlcappuccino/" % api_dir)
os.system("chown -R cruise:www-data %s/growlcappuccino/" % api_dir)
os.system("echo \* Generating doc for TNKit")
os.system("mkdir -p %s/tnkit" % api_dir)
os.system("cd ./ArchipelClient/Libraries/TNKit; jake docs")
os.system("cp -a ./ArchipelClient/Libraries/TNKit/Build/Documentation/html/* %s/tnkit/" % api_dir)
os.system("chown -R cruise:www-data %s/tnkit/" % api_dir)
os.system("echo \* Generating doc for ArchipelAgent")
os.system("mkdir -p %s/archipel-agent" % api_dir)
os.system("cd ArchipelAgent; epydoc --config=epydoc.conf")
os.system("cp -a ArchipelAgent/html/* %s/archipel-agent/" % api_dir)
os.system("chown -R cruise:www-data %s/archipel-agent/" % api_dir)
os.system("echo \* Documentation generation complete")
if __name__ == "__main__":
"""
Simple script that can be run using CruiseControl.rb to make continuous integration
"""
ret, out = commands.getstatusoutput("git log -n1")
if "#nobuild" in out:
os.system("echo \* Build skipped according to last commit message (contains #nobuild)")
sys.exit(0)
updateSubmodules()
if BUILD_CAPPUCCINO or FORCE: buildCappuccino()
if BUILD_GROWLCAPPUCCINO or FORCE: buildGrowlCappuccino()
if BUILD_LPKIT or FORCE: buildLPKit()
if BUILD_STROPHECAPPUCCINO or FORCE: buildStropheCappuccino()
if BUILD_TNKIT or FORCE: buildTNKit()
if BUILD_VNCCAPPUCCINO or FORCE: buildVNCCappuccino()
buildArchipel(EXPORT_PATH, BUILD_ARCHIPELCLIENT)
deployArchipel(DEPLOY_PATH)
generateAPI(API_PATH)
os.system("echo \* BUILD SUCESSFULL.")
sys.exit(0)