-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster.cfg
executable file
·459 lines (375 loc) · 19 KB
/
master.cfg
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# ex: set syntax=python:
# Scipion master config file.
import os
# Buildbot configuration dictionary (and alias)
c = BuildmasterConfig = {}
##############################################################################
# BUILDSLAVES
# -----------------------------------------------------------------------------
# The Scipion 'slaves' list. Slaves were also configured with that
# password when created.
# if you change something, check all the occurrences along this file
##############################################################################
from buildbot.plugins import *
from settings import (WORKER, WORKER_PASS, PORT, DOCS_PREFIX, WEBSITE_PREFIX, CHECK_PLUGINS_DIFF, WORKER1)
# nolan should be able to handle all tests, big or small
c['workers'] = [worker.Worker(WORKER, WORKER_PASS),
worker.Worker(WORKER1, WORKER_PASS)]
# 'slavePortnum' defines the TCP port to listen on for connections from slaves.
# This match the value configured into the buildslaves (using --master option)
c['protocols'] = {"pb": {"port": PORT}}
from buildbot.steps.shell import ShellCommand
# *****************************************************************************
# *****************************************************************************
# BUILD FACTORIES
# *****************************************************************************
# *****************************************************************************
# *****************************************************************************
# BUILD GROUP FACTORY
# *****************************************************************************
# This one orchestrates everything: installs scipion, xmipp, plugins and performs
# their tests.
from buildbot.plugins import steps
from settings import (SCIPION_BUILD_ID, CLEANUP_PREFIX, SCIPION_INSTALL_PREFIX,
SCIPION_TESTS_PREFIX, XMIPP_BUNDLE_TESTS, XMIPP_TESTS,
SPROD_GROUP_ID, PROD_GROUP_ID, SDEVEL_GROUP_ID,
XMIPP_INSTALL_PREFIX, XMIPP_DOCS_PREFIX)
from master_scipion import (scipionPlugins, locscalePluginData,
scipionSdevelPlugins, locscaleSdevelPluginData)
def isSaturday(step):
from datetime import datetime
return datetime.today().weekday() == 5
def isSunday(step):
from datetime import datetime
return datetime.today().weekday() == 6
def setCommonProperties(groupId, factorySteps=None):
factorySteps = factorySteps or util.BuildFactory()
factorySteps.addStep(steps.SetPropertyFromCommand(command="echo $PWD",
property="SCIPION_HOME",
name="Set SCIPION_HOME",
description="Set SCIPION_HOME",
descriptionDone="SCIPION_HOME set"))
factorySteps.addStep(steps.SetProperty(property='SCIPION_LOCAL_CONFIG',
value="~/%s/scipion/config/scipion.conf" % groupId,
name="Set SCIPION_LOCAL_CONFIG",
description="Set SCIPION_LOCAL_CONFIG",
descriptionDone="SCIPION_LOCAL_CONFIG set"))
factorySteps.addStep(steps.SetPropertyFromCommand(command='echo $(dirname "$(pwd)")',
property="BUILD_GROUP_HOME",
name="Set BUILD_GROUP_HOME",
description="Set BUILD_GROUP_HOME",
descriptionDone="BUILD_GROUP_HOME set"
))
return factorySteps
def prodBuildGroupFactory():
groupId = SPROD_GROUP_ID
factorySteps = util.BuildFactory()
factorySteps.workdir = SCIPION_BUILD_ID
setCommonProperties(groupId, factorySteps)
props = {
"SCIPION_HOME": util.Property("SCIPION_HOME"),
"SCIPION_LOCAL_CONFIG": util.Property("SCIPION_LOCAL_CONFIG"),
"BUILD_GROUP_HOME": util.Property("BUILD_GROUP_HOME")}
factorySteps.addStep(
steps.Trigger(schedulerNames=[CLEANUP_PREFIX + groupId],
doStepIf=isSaturday,
waitForFinish=True,
set_properties=props))
factorySteps.addStep(
steps.Trigger(schedulerNames=[SCIPION_INSTALL_PREFIX + groupId],
waitForFinish=True,
haltOnFailure=True,
set_properties=props))
props = {
'SCIPION_HOME': util.Property("SCIPION_HOME"),
"SCIPION_LOCAL_CONFIG": util.Property("SCIPION_LOCAL_CONFIG")
}
stepSchedulerNames = []
stepSchedulerNames += ["%s_%s" % (str(p.get("name", pname.rsplit('-')[-1])),
groupId) for pname, p in
scipionSdevelPlugins.items()]
stepSchedulerNames.append(
'%s_%s' % (str(locscaleSdevelPluginData['name']), groupId))
stepSchedulerNames += [XMIPP_TESTS + groupId,
SCIPION_TESTS_PREFIX + groupId]
for schedulerName in stepSchedulerNames:
factorySteps.addStep(
steps.Trigger(schedulerNames=[schedulerName],
waitForFinish=True,
set_properties=props,
haltOnFailure=False))
return factorySteps
def sdevelBuildGroupFactory():
groupId = SDEVEL_GROUP_ID
factorySteps = util.BuildFactory()
factorySteps.workdir = SCIPION_BUILD_ID
setCommonProperties(groupId, factorySteps)
props = {
"SCIPION_HOME": util.Property("SCIPION_HOME"),
"SCIPION_LOCAL_CONFIG": util.Property("SCIPION_LOCAL_CONFIG"),
"BUILD_GROUP_HOME": util.Property("BUILD_GROUP_HOME")}
# put doStepIf=isSaturday to launch the builder this specific day
factorySteps.addStep(
steps.Trigger(schedulerNames=[CLEANUP_PREFIX + groupId],
waitForFinish=True,
set_properties=props))
factorySteps.addStep(
steps.Trigger(schedulerNames=[SCIPION_INSTALL_PREFIX + groupId],
waitForFinish=True,
haltOnFailure=True,
set_properties=props))
props = {
'SCIPION_HOME': util.Property("SCIPION_HOME"),
"SCIPION_LOCAL_CONFIG": util.Property("SCIPION_LOCAL_CONFIG")
}
stepSchedulerNames = ["%s" % XMIPP_BUNDLE_TESTS + groupId]
stepSchedulerNames += ["%s_%s" % (str(p.get("name", pname.rsplit('-')[-1])),
groupId) for pname, p in scipionSdevelPlugins.items()]
stepSchedulerNames.append(
'%s_%s' % (str(locscaleSdevelPluginData['name']), groupId))
stepSchedulerNames += [XMIPP_TESTS + groupId, SCIPION_TESTS_PREFIX + groupId]
stepSchedulerNames += [DOCS_PREFIX + groupId]
stepSchedulerNames += [XMIPP_DOCS_PREFIX + groupId]
stepSchedulerNames += [WEBSITE_PREFIX + groupId]
stepSchedulerNames += [CHECK_PLUGINS_DIFF + groupId]
for schedulerName in stepSchedulerNames:
factorySteps.addStep(
steps.Trigger(schedulerNames=[schedulerName],
waitForFinish=True,
set_properties=props,
haltOnFailure=False))
return factorySteps
##############################################################################
# ****************************************************************************
# BUILDERS
# ****************************************************************************
##############################################################################
from buildbot.config import BuilderConfig
from settings import branchsDict
from master_scipion import getScipionBuilders
from master_xmipp import getXmippBuilders
# Create the builders.
c['builders'] = []
c['builders'].append(
BuilderConfig(name=SDEVEL_GROUP_ID,
workernames=[WORKER1],
tags=[SDEVEL_GROUP_ID],
factory=sdevelBuildGroupFactory(),
workerbuilddir=SDEVEL_GROUP_ID,
env={"SCIPION_IGNORE_PYTHONPATH": "True"}))
c['builders'].append(
BuilderConfig(name=SPROD_GROUP_ID,
workernames=[WORKER1],
tags=[SPROD_GROUP_ID],
factory=prodBuildGroupFactory(),
workerbuilddir=SPROD_GROUP_ID,
env={"SCIPION_IGNORE_PYTHONPATH": "True"}))
for groupId in branchsDict:
c['builders'] += getScipionBuilders(groupId)
c['builders'] += getXmippBuilders(groupId)
##############################################################################
# SCHEDULERS
# -----------------------------------------------------------------------------
# Schedulers decide how to react to incoming changes.
##############################################################################
from buildbot.schedulers import timed, triggerable
from buildbot.schedulers.forcesched import ForceScheduler
from settings import FORCE_BUILDER_PREFIX, SPROD_GROUP_ID
c['schedulers'] = []
# *****************************************************************************
# Periodic
# http://docs.buildbot.net/latest/manual/cfg-schedulers.html#sched-Periodic
# *****************************************************************************
from master_scipion import getScipionSchedulers
from master_xmipp import getXmippSchedulers
weekDays = {0: 'Mon.', 1: 'Tue.', 2: 'Wed.', 3: 'Thu.', 4: 'Fri.', 5: 'Sat.', 6: 'Sun.'}
triggerableSchedulers = [] # ['Specific_Branch_Tests']
c['schedulers'].append(timed.Nightly(
name=SPROD_GROUP_ID,
builderNames=[SPROD_GROUP_ID],
dayOfWeek=[4],
hour=17, # one less in Spain (CET) => hour=15 will start at 14:00(GMT+1)
minute=00))
c['schedulers'].append(timed.Nightly(
name=SDEVEL_GROUP_ID,
builderNames=[SDEVEL_GROUP_ID],
dayOfWeek=[0],
hour=00, # one less in Spain (CET) => hour=15 will start at 14:00(GMT+1)
minute=00))
# Prod builds every sunday
# c['schedulers'].append(timed.Nightly(
# name=PROD_GROUP_ID,
# builderNames=[PROD_GROUP_ID],
# dayOfWeek=[4],
# hour=17, # one less in Spain (CET) => hour=15 will start at 14:00(GMT+1)
# minute=00))
for index, (groupId, groupBranches) in enumerate(branchsDict.items()):
# # Assign every branch to some week days to have alternate schedulers.
# # For two branches (i.e. master and devel) we have:
# # - Monday, Wendesday, Friday and Sunday for master
# # - Tuesday, Thursday and Saturday for devel
# days = [day + index for day in range(7 - index) if day % len(branchsDict) == 0]
# print(' > > > branch %s will be test on %s < < <'
# % (groupBranches[SCIPION_BUILD_ID], ', '.join([weekDays[day] for day in days])))
# c['schedulers'].append(timed.Nightly(
# name=groupId,
# builderNames=[groupId],
# dayOfWeek=days,
# hour=0, minute=30))
# c['schedulers'].append(triggerable.Triggerable(
# name=groupId,
# builderNames=[groupId]))
c['schedulers'].append(ForceScheduler(
name=FORCE_BUILDER_PREFIX + groupId,
builderNames=[groupId]))
c['schedulers'] += getScipionSchedulers(groupId)
c['schedulers'] += getXmippSchedulers(groupId)
##############################################################################
# WEB ACCESS
##############################################################################
from buildbot.www import auth
from buildbot.plugins import util
from settings import WEB_PORT, WEB_URL
c['www'] = dict(port=WEB_PORT,
plugins=dict(waterfall_view={},
console_view={},
badges={}),
change_hook_dialects={'github': {}},
auth=util.UserPasswordAuth({"admin": "bu1ldb0t."}))
##############################################################################
# PROJECT IDENTITY
##############################################################################
# the 'title' string will appear at the top of this buildbot
# installation's html.WebStatus home page (linked to the
# 'titleURL') and is embedded in the title of the waterfall HTML page.
c['title'] = 'Scipion Automatic Tests'
c['titleURL'] = 'http://scipion.cnb.csic.es/docs/bin/view/TWiki/RunningTests/'
# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server (usually the html.WebStatus page) is visible. This
# typically uses the port number set in the Waterfall 'status' entry, but
# with an externally-visible host name which the buildbot cannot figure out
# without some help.
c['buildbotURL'] = WEB_URL
##############################################################################
# DB URL
##############################################################################
# This specifies what database buildbot uses to store its state. You can leave
# this at its default for all but the largest installations.
c['db'] = {
'db_url': 'sqlite:///state.sqlite',
}
##############################################################################
# MAIL NOTIFICATIONS
##############################################################################
c['services'] = []
def bbot2Slack(build):
from buildbot.process.results import FAILURE
result = build['results']
if result == FAILURE and result is not None:
builderid = build['builderid']
builderName = build['properties']['buildername'][0]
if builderName in branchsDict or PROD_GROUP_ID in builderName: # master builder doesnt report
return
channel = build['properties']['slackChannel'][0]
if channel == "":
return
msgJson = dict()
msgStr = ("<%s|%s - %s> is failing.\nShame on you! :rage:, please fix it ASAP."
% (build['url'], builderName, build['number']))
failsStr = ' (failure)\n\t - '.join(build['state_string'].split(' (failure) '))
msgStr += "\nStatus is: " + 'Failed\n\t - ' + failsStr.strip('failed ')
msgJson["text"] = msgStr
msgJson["channel"] = "#%s" % channel
return msgJson
from buildbot.plugins import reporters
sp = reporters.HttpStatusPush(
serverUrl="https://hooks.slack.com/services/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"
# format_fn=bbot2Slack,
# wantProperties=True)
)
if os.environ.get('DONT_NOTIFY_SLACK', True) is False:
c['services'].append(sp)
class MailNotifier:
def __init__(self):
self.fromaddr = os.getenv("BUILDBOT_NOTIFIER_MAIL_FROM_ADDR")
self.smtpUser = os.getenv("BUILDBOT_NOTIFIER_MAIL_USER")
self.smtpPassword = os.getenv("BUILDBOT_NOTIFIER_MAIL_PASSWORD")
self.relayhost = os.getenv("BUILDBOT_NOTIFIER_RELAY_HOST")
self.smtpPort = int(os.getenv("BUILDBOT_NOTIFIER_SMTP_PORT"))
self.template = u'''\
<h4>Build status: {{ summary }}</h4>
<p> Worker used: {{ workername }}</p>
<a href="{{ build_url }}"> Click here to go to Buildbot </a>
{% for step in build['steps'] %}
<p> {{ step['name'] }}: {{ step['results'] }}</p>
{% endfor %}
<p><b> Scipion Buildbot</b></p>
'''
def mailNotifier(self, builders, extraRecipients):
mn = None
if self.smtpUser is not None and self.smtpPassword is not None:
mn = reporters.MailNotifier(fromaddr=self.fromaddr,
# mode='failing',
# builders=builders,
extraRecipients=extraRecipients,
sendToInterestedUsers=False,
# messageFormatter=reporters.MessageFormatter(
# template=self.template,
# template_type='html'),
relayhost=self.relayhost,
smtpPort=self.smtpPort,
smtpUser=self.smtpUser,
smtpPassword=self.smtpPassword
)
return mn
def runNotifier(self):
# xmipp Notifier
mn = self.mailNotifier(builders=['xmipp_devel', 'xmipp_bundle_devel'],
extraRecipients=['[email protected]',
if mn is not None:
c['services'].append(mn)
# Cryosparc Notifier
mn = self.mailNotifier(builders=['cryosparc2_devel'],
extraRecipients=['[email protected]'])
if mn is not None:
c['services'].append(mn)
# Relion Notifier
mn = self.mailNotifier(builders=['relion_devel'],
extraRecipients=['[email protected]'])
if mn is not None:
c['services'].append(mn)
# Tomo plugins Notifier
mn = self.mailNotifier(builders=['dynamo_devel',
'imod_devel',
'novactf_devel',
'tomo_devel',
'pyseg_devel',
'xmipp2_devel',
'xmipptomo_devel',
'deepfinder_devel',
'tomoj_devel',
'sidesplitter_devel',
'emantomo_devel',
'reliontomo_devel',
'jjsoft_devel',
'cryocare_devel',
'tomo3D_devel'],
extraRecipients=['[email protected]',
if mn is not None:
c['services'].append(mn)
# MailNotifier().runNotifier()
c['changeHorizon'] = 50
# c['buildHorizon'] = 10
# c['logHorizon'] = 5
c['buildCacheSize'] = 15