forked from catlee/buildbotcustom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.py
3796 lines (3500 loc) · 175 KB
/
misc.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
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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from urlparse import urljoin
try:
import json
assert json # pyflakes
except:
import simplejson as json
import collections
import random
import re
import sys, os, time
from copy import deepcopy
from twisted.python import log
from buildbot.scheduler import Nightly, Scheduler, Triggerable
from buildbot.status.tinderbox import TinderboxMailNotifier
from buildbot.steps.shell import WithProperties
from buildbot.status.builder import WARNINGS, FAILURE, EXCEPTION, RETRY
from buildbot.process.buildstep import regex_log_evaluator
import buildbotcustom.common
import buildbotcustom.changes.hgpoller
import buildbotcustom.process.factory
import buildbotcustom.log
import buildbotcustom.l10n
import buildbotcustom.scheduler
import buildbotcustom.status.mail
import buildbotcustom.status.generators
import buildbotcustom.status.queued_command
import buildbotcustom.status.log_handlers
import buildbotcustom.misc_scheduler
import build.paths
import mozilla_buildtools.queuedir
reload(buildbotcustom.changes.hgpoller)
reload(buildbotcustom.process.factory)
reload(buildbotcustom.log)
reload(buildbotcustom.l10n)
reload(buildbotcustom.scheduler)
reload(buildbotcustom.status.mail)
reload(buildbotcustom.status.generators)
reload(buildbotcustom.status.queued_command)
reload(buildbotcustom.status.log_handlers)
reload(buildbotcustom.misc_scheduler)
reload(build.paths)
reload(mozilla_buildtools.queuedir)
from buildbotcustom.common import reallyShort
from buildbotcustom.changes.hgpoller import HgPoller, HgAllLocalesPoller
from buildbotcustom.process.factory import NightlyBuildFactory, \
NightlyRepackFactory, UnittestBuildFactory, CodeCoverageFactory, \
UnittestPackagedBuildFactory, TalosFactory, CCNightlyBuildFactory, \
CCNightlyRepackFactory, CCUnittestBuildFactory, TryBuildFactory, \
TryUnittestBuildFactory, ScriptFactory, rc_eval_func
from buildbotcustom.process.factory import RemoteUnittestFactory
from buildbotcustom.scheduler import MultiScheduler, BuilderChooserScheduler, \
PersistentScheduler, makePropertiesScheduler, SpecificNightly
from buildbotcustom.l10n import TriggerableL10n
from buildbotcustom.status.mail import MercurialEmailLookup, ChangeNotifier
from buildbotcustom.status.generators import buildTryChangeMessage
from buildbotcustom.env import MozillaEnvironments
from buildbotcustom.misc_scheduler import tryChooser, buildIDSchedFunc, \
buildUIDSchedFunc, lastGoodFunc
from buildbotcustom.status.queued_command import QueuedCommandHandler
from buildbotcustom.status.log_handlers import SubprocessLogHandler
from build.paths import getRealpath
from mozilla_buildtools.queuedir import QueueDir
# This file contains misc. helper function that don't make sense to put in
# other files. For example, functions that are called in a master.cfg
def get_l10n_repositories(file, l10nRepoPath, relbranch):
"""Reads in a list of locale names and revisions for their associated
repository from 'file'.
"""
if not l10nRepoPath.endswith('/'):
l10nRepoPath = l10nRepoPath + '/'
repositories = {}
for localeLine in open(file).readlines():
locale, revision = localeLine.rstrip().split()
if revision == 'FIXME':
raise Exception('Found FIXME in %s for locale "%s"' % \
(file, locale))
locale = urljoin(l10nRepoPath, locale)
repositories[locale] = {
'revision': revision,
'relbranchOverride': relbranch,
'bumpFiles': []
}
return repositories
def get_locales_from_json(jsonFile, l10nRepoPath, relbranch):
if not l10nRepoPath.endswith('/'):
l10nRepoPath = l10nRepoPath + '/'
l10nRepositories = {}
platformLocales = collections.defaultdict(dict)
file = open(jsonFile)
localesJson = json.load(file)
for locale in localesJson.keys():
revision = localesJson[locale]['revision']
if revision == 'FIXME':
raise Exception('Found FIXME in %s for locale "%s"' % \
(jsonFile, locale))
localeUrl = urljoin(l10nRepoPath, locale)
l10nRepositories[localeUrl] = {
'revision': revision,
'relbranchOverride': relbranch,
'bumpFiles': []
}
for platform in localesJson[locale]['platforms']:
platformLocales[platform][locale] = localesJson[locale]['platforms']
return (l10nRepositories, platformLocales)
# This function is used as fileIsImportant parameter for Buildbots that do both
# dep/nightlies and release builds. Because they build the same "branch" this
# allows us to have the release builder ignore HgPoller triggered changse
# and the dep builders only obey HgPoller/Force Build triggered ones.
def isHgPollerTriggered(change, hgUrl):
if (change.revlink and hgUrl in change.revlink) or \
change.comments.find(hgUrl) > -1:
return True
def shouldBuild(change):
"""check for commit message disabling build for this change"""
return "DONTBUILD" not in change.comments
def isImportantL10nFile(change, l10nModules):
for f in change.files:
for basepath in l10nModules:
if f.startswith(basepath):
return True
return False
def changeContainsProduct(change, productName):
products = change.properties.getProperty("products")
if isinstance(products, basestring) and \
productName in products.split(','):
return True
return False
def changeContainsProperties(change, props={}):
for prop, value in props.iteritems():
if change.properties.getProperty(prop) != value:
return False
return True
def generateTestBuilderNames(name_prefix, suites_name, suites):
test_builders = []
if isinstance(suites, dict) and "totalChunks" in suites:
totalChunks = suites['totalChunks']
for i in range(totalChunks):
test_builders.append('%s %s-%i/%i' % \
(name_prefix, suites_name, i+1, totalChunks))
else:
test_builders.append('%s %s' % (name_prefix, suites_name))
return test_builders
fastRegexes = []
nReservedFastSlaves = 0
nReservedSlowSlaves = 0
def _partitionSlaves(slaves):
"""Partitions the list of slaves into 'fast' and 'slow' slaves, according
to fastRegexes.
Returns two lists, 'fast' and 'slow'."""
fast = []
slow = []
for s in slaves:
name = s.slave.slavename
for e in fastRegexes:
if re.search(e, name):
fast.append(s)
break
else:
slow.append(s)
return fast, slow
def _partitionUnreservedSlaves(slaves):
fast, slow = _partitionSlaves(slaves)
return fast[nReservedFastSlaves:], slow[nReservedSlowSlaves:]
def _readReservedFile(filename, fast=True):
if not filename or not os.path.exists(filename):
n = 0
else:
try:
data = open(filename).read().strip()
if data == '':
n = 0
else:
n = int(data)
except IOError:
log.msg("Unable to open '%s' for reading" % filename)
log.err()
return
except ValueError:
log.msg("Unable to read '%s' as an integer" % filename)
log.err()
return
global nReservedSlowSlaves, nReservedFastSlaves
if fast:
if n != nReservedFastSlaves:
log.msg("Setting nReservedFastSlaves to %i (was %i)" % (n, nReservedFastSlaves))
nReservedFastSlaves = n
else:
if n != nReservedSlowSlaves:
log.msg("Setting nReservedSlowSlaves to %i (was %i)" % (n, nReservedSlowSlaves))
nReservedSlowSlaves = n
def _getLastTimeOnBuilder(builder, slavename):
# New builds are at the end of the buildCache, so
# examine it backwards
buildNumbers = reversed(sorted(builder.builder_status.buildCache.keys()))
for buildNumber in buildNumbers:
try:
build = builder.builder_status.buildCache[buildNumber]
if build.slavename == slavename:
return build.finished
except KeyError:
continue
return None
def _recentSort(builder):
def sortfunc(s1, s2):
t1 = _getLastTimeOnBuilder(builder, s1.slave.slavename)
t2 = _getLastTimeOnBuilder(builder, s2.slave.slavename)
return cmp(t1, t2)
return sortfunc
def _nextSlowSlave(builder, available_slaves):
try:
fast, slow = _partitionUnreservedSlaves(available_slaves)
# Choose the slow slave that was most recently on this builder
# If there aren't any slow slaves, choose the slow slave that was most
# recently on this builder
if slow:
return sorted(slow, _recentSort(builder))[-1]
elif fast:
return sorted(fast, _recentSort(builder))[-1]
else:
return None
except:
log.msg("Error choosing next slow slave for builder '%s', choosing randomly instead" % builder.name)
log.err()
return random.choice(available_slaves)
def _nextFastSlave(builder, available_slaves, only_fast=False, reserved=False):
# Check if our reserved slaves count needs updating
global _checkedReservedSlaveFile, _reservedFileName
if int(time.time() - _checkedReservedSlaveFile) > 60:
_readReservedFile(_reservedFileName)
_checkedReservedSlaveFile = int(time.time())
try:
if only_fast:
# Check that the builder has some fast slaves configured. We do
# this because some machines classes don't have a fast/slow
# distinction, and so they default to 'slow'
# We should look at the full set of slaves here regardless of if
# we're only supposed to be returning unreserved slaves so we get
# the full set of slaves on the builder.
fast, slow = _partitionSlaves(builder.slaves)
if not fast:
log.msg("Builder '%s' has no fast slaves configured, but only_fast is enabled; disabling only_fast" % builder.name)
only_fast = False
if reserved:
# We have access to the full set of slaves!
fast, slow = _partitionSlaves(available_slaves)
else:
# We only have access to unreserved slaves
fast, slow = _partitionUnreservedSlaves(available_slaves)
# Choose the fast slave that was most recently on this builder
# If there aren't any fast slaves, choose the slow slave that was most
# recently on this builder if only_fast is False
if not fast and only_fast:
return None
elif fast:
return sorted(fast, _recentSort(builder))[-1]
elif slow and not only_fast:
return sorted(slow, _recentSort(builder))[-1]
else:
return None
except:
log.msg("Error choosing next fast slave for builder '%s', choosing randomly instead" % builder.name)
log.err()
return random.choice(available_slaves)
_checkedReservedSlaveFile = 0
_reservedFileName = None
def setReservedFileName(filename):
global _reservedFileName
_reservedFileName = filename
def _nextFastReservedSlave(builder, available_slaves, only_fast=True):
return _nextFastSlave(builder, available_slaves, only_fast, reserved=True)
def _nextL10nSlave(n=4):
"""Return a nextSlave function that restricts itself to choosing amongst
the first n connnected slaves. If there aren't enough slow slaves,
fallback to using fast slaves."""
def _nextslave(builder, available_slaves):
try:
# Determine our list of the first n connected slaves, preferring to use slow slaves
# if available.
connected_slaves = [s for s in builder.slaves if s.slave.slave_status.isConnected()]
# Sort the list so we're stable across reconfigs
connected_slaves.sort(key=lambda s: s.slave.slavename)
fast, slow = _partitionUnreservedSlaves(connected_slaves)
slow = slow[:n]
# Choose enough fast slaves so that we're considering a total of n slaves
fast = fast[:n-(len(slow))]
# Now keep only those that are in available_slaves
slow = [s for s in slow if s in available_slaves]
fast = [s for s in fast if s in available_slaves]
# Now prefer slaves that most recently did this repack
if slow:
return sorted(slow, _recentSort(builder))[-1]
elif fast:
return sorted(fast, _recentSort(builder))[-1]
else:
# That's ok!
return None
except:
log.msg("Error choosing l10n slave for builder '%s', choosing randomly instead" % builder.name)
log.err()
return random.choice(available_slaves)
return _nextslave
def _nextSlowIdleSlave(nReserved):
"""Return a nextSlave function that will only return a slave to run a build
if there are at least nReserved slaves available."""
def _nextslave(builder, available_slaves):
fast, slow = _partitionUnreservedSlaves(available_slaves)
if len(slow) <= nReserved:
return None
return sorted(slow, _recentSort(builder))[-1]
return _nextslave
nomergeBuilders = []
def mergeRequests(builder, req1, req2):
if builder.name in nomergeBuilders:
return False
return req1.canBeMergedWith(req2)
def mergeBuildObjects(d1, d2):
retval = d1.copy()
keys = ['builders', 'status', 'schedulers', 'change_source']
for key in keys:
retval.setdefault(key, []).extend(d2.get(key, []))
return retval
def generateTestBuilder(config, branch_name, platform, name_prefix,
build_dir_prefix, suites_name, suites,
mochitestLeakThreshold, crashtestLeakThreshold,
slaves=None, resetHwClock=False, category=None,
stagePlatform=None, stageProduct=None,
mozharness=False, mozharness_python=None):
builders = []
pf = config['platforms'].get(platform, {})
if slaves == None:
slavenames = config['platforms'][platform]['slaves']
else:
slavenames = slaves
if not category:
category = branch_name
productName = pf['product_name']
branchProperty = branch_name
posixBinarySuffix = '' if 'mobile' in name_prefix else '-bin'
properties = {'branch': branchProperty, 'platform': platform,
'slavebuilddir': 'test', 'stage_platform': stagePlatform,
'product': stageProduct}
if pf.get('is_remote', False):
hostUtils = pf['host_utils_url']
factory = RemoteUnittestFactory(
platform=platform,
productName=productName,
hostUtils=hostUtils,
suites=suites,
hgHost=config['hghost'],
repoPath=config['repo_path'],
buildToolsRepoPath=config['build_tools_repo_path'],
branchName=branch_name,
remoteExtras=pf.get('remote_extras'),
downloadSymbols=pf.get('download_symbols', True),
)
builder = {
'name': '%s %s' % (name_prefix, suites_name),
'slavenames': slavenames,
'builddir': '%s-%s' % (build_dir_prefix, suites_name),
'slavebuilddir': 'test',
'factory': factory,
'category': category,
'properties': properties,
}
builders.append(builder)
elif mozharness:
# suites is a dict!
extra_args = suites.get('extra_args', [])
factory = ScriptFactory(
interpreter=mozharness_python,
scriptRepo=suites['mozharness_repo'],
scriptName=suites['script_path'],
hg_bin=suites['hg_bin'],
extra_args=suites.get('extra_args', []),
reboot_command=suites.get('reboot_command'),
log_eval_func=lambda c,s: regex_log_evaluator(c, s, (
(re.compile('# TBPL WARNING #'), WARNINGS),
(re.compile('# TBPL FAILURE #'), FAILURE),
(re.compile('# TBPL EXCEPTION #'), EXCEPTION),
(re.compile('# TBPL RETRY #'), RETRY),
))
)
builder = {
'name': '%s %s' % (name_prefix, suites_name),
'slavenames': slavenames,
'builddir': '%s-%s' % (build_dir_prefix, suites_name),
'slavebuilddir': 'test',
'factory': factory,
'category': category,
'properties': properties,
}
builders.append(builder)
else:
if isinstance(suites, dict) and "totalChunks" in suites:
totalChunks = suites['totalChunks']
for i in range(totalChunks):
factory = UnittestPackagedBuildFactory(
platform=platform,
test_suites=[suites['suite']],
mochitest_leak_threshold=mochitestLeakThreshold,
crashtest_leak_threshold=crashtestLeakThreshold,
hgHost=config['hghost'],
repoPath=config['repo_path'],
productName=productName,
posixBinarySuffix=posixBinarySuffix,
buildToolsRepoPath=config['build_tools_repo_path'],
buildSpace=1.0,
buildsBeforeReboot=config['platforms'][platform]['builds_before_reboot'],
totalChunks=totalChunks,
thisChunk=i+1,
chunkByDir=suites.get('chunkByDir'),
env=pf.get('unittest-env', {}),
downloadSymbols=pf.get('download_symbols', True),
resetHwClock=resetHwClock,
stackwalk_cgi=config.get('stackwalk_cgi'),
)
builder = {
'name': '%s %s-%i/%i' % (name_prefix, suites_name, i+1, totalChunks),
'slavenames': slavenames,
'builddir': '%s-%s-%i' % (build_dir_prefix, suites_name, i+1),
'slavebuilddir': 'test',
'factory': factory,
'category': category,
'nextSlave': _nextSlowSlave,
'properties': properties,
'env' : MozillaEnvironments.get(config['platforms'][platform].get('env_name'), {}),
}
builders.append(builder)
else:
factory = UnittestPackagedBuildFactory(
platform=platform,
test_suites=suites,
mochitest_leak_threshold=mochitestLeakThreshold,
crashtest_leak_threshold=crashtestLeakThreshold,
hgHost=config['hghost'],
repoPath=config['repo_path'],
productName=productName,
posixBinarySuffix=posixBinarySuffix,
buildToolsRepoPath=config['build_tools_repo_path'],
buildSpace=1.0,
buildsBeforeReboot=config['platforms'][platform]['builds_before_reboot'],
downloadSymbols=pf.get('download_symbols', True),
env=pf.get('unittest-env', {}),
resetHwClock=resetHwClock,
stackwalk_cgi=config.get('stackwalk_cgi'),
)
builder = {
'name': '%s %s' % (name_prefix, suites_name),
'slavenames': slavenames,
'builddir': '%s-%s' % (build_dir_prefix, suites_name),
'slavebuilddir': 'test',
'factory': factory,
'category': category,
'properties': properties,
'env' : MozillaEnvironments.get(config['platforms'][platform].get('env_name'), {}),
}
builders.append(builder)
return builders
def generateBranchObjects(config, name, secrets=None):
"""name is the name of branch which is usually the last part of the path
to the repository. For example, 'mozilla-central', 'mozilla-aurora', or
'mozilla-1.9.1'.
config is a dictionary containing all of the necessary configuration
information for a branch. The required keys depends greatly on what's
enabled for a branch (unittests, xulrunner, l10n, etc). The best way
to figure out what you need to pass is by looking at existing configs
and using 'buildbot checkconfig' to verify.
"""
# We return this at the end
branchObjects = {
'builders': [],
'change_source': [],
'schedulers': [],
'status': []
}
if secrets is None:
secrets = {}
builders = []
unittestBuilders = []
triggeredUnittestBuilders = []
nightlyBuilders = []
xulrunnerNightlyBuilders = []
periodicPgoBuilders = [] # Only used for the 'periodic' strategy. rename to perodicPgoBuilders?
debugBuilders = []
weeklyBuilders = []
coverageBuilders = []
# prettyNames is a mapping to pass to the try_parser for validation
PRETTY_NAME = '%s build'
prettyNames = {}
unittestPrettyNames = {}
unittestSuites = []
# These dicts provides mapping between en-US dep and nightly scheduler names
# to l10n dep and l10n nightly scheduler names. It's filled out just below here.
l10nBuilders = {}
l10nNightlyBuilders = {}
pollInterval = config.get('pollInterval', 60)
l10nPollInterval = config.get('l10nPollInterval', 5*60)
# We only understand a couple PGO strategies
assert config['pgo_strategy'] in ('per-checkin', 'periodic', None), \
"%s is not an understood PGO strategy" % config['pgo_strategy']
# This section is to make it easier to disable certain products.
# Ideally we could specify a shorter platforms key on the branch,
# but that doesn't work
enabled_platforms = []
for platform in sorted(config['platforms'].keys()):
pf = config['platforms'][platform]
if pf['stage_product'] in config['enabled_products']:
enabled_platforms.append(platform)
# generate a list of builders, nightly builders (names must be different)
# for easy access
for platform in enabled_platforms:
pf = config['platforms'][platform]
base_name = pf['base_name']
pretty_name = PRETTY_NAME % base_name
if platform.endswith("-debug"):
debugBuilders.append(pretty_name)
prettyNames[platform] = pretty_name
# Debug unittests
if pf.get('enable_unittests'):
test_builders = []
if 'opt_base_name' in config['platforms'][platform]:
base_name = config['platforms'][platform]['opt_base_name']
else:
base_name = config['platforms'][platform.replace("-debug", "")]['base_name']
for suites_name, suites in config['unittest_suites']:
unittestPrettyNames[platform] = '%s debug test' % base_name
test_builders.extend(generateTestBuilderNames('%s debug test' % base_name, suites_name, suites))
triggeredUnittestBuilders.append(('%s-%s-unittest' % (name, platform), test_builders, config.get('enable_merging', True)))
# Skip l10n, unit tests
# Skip nightlies for debug builds unless requested
if not pf.has_key('enable_nightly'):
continue
elif pf.get('enable_dep', True):
builders.append(pretty_name)
prettyNames[platform] = pretty_name
# Fill the l10n dep dict
if config['enable_l10n'] and platform in config['l10n_platforms'] and \
config['enable_l10n_onchange']:
l10nBuilders[base_name] = {}
l10nBuilders[base_name]['tree'] = config['l10n_tree']
l10nBuilders[base_name]['l10n_builder'] = \
'%s %s %s l10n dep' % (pf['product_name'].capitalize(),
name, platform)
l10nBuilders[base_name]['platform'] = platform
# Check if branch wants nightly builds
if config['enable_nightly']:
if pf.has_key('enable_nightly'):
do_nightly = pf['enable_nightly']
else:
do_nightly = True
else:
do_nightly = False
# Check if platform as a PGO builder
if config['pgo_strategy'] == 'periodic' and platform in config['pgo_platforms']:
periodicPgoBuilders.append('%s pgo-build' % pf['base_name'])
if do_nightly:
builder = '%s nightly' % base_name
nightlyBuilders.append(builder)
# Fill the l10nNightly dict
if config['enable_l10n'] and platform in config['l10n_platforms']:
l10nNightlyBuilders[builder] = {}
l10nNightlyBuilders[builder]['tree'] = config['l10n_tree']
l10nNightlyBuilders[builder]['l10n_builder'] = \
'%s %s %s l10n nightly' % (pf['product_name'].capitalize(),
name, platform)
l10nNightlyBuilders[builder]['platform'] = platform
if config['enable_shark'] and pf.get('enable_shark'):
nightlyBuilders.append('%s shark' % base_name)
if config['enable_valgrind'] and \
platform in config['valgrind_platforms']:
nightlyBuilders.append('%s valgrind' % base_name)
# Regular unittest builds
if pf.get('enable_unittests'):
unittestBuilders.append('%s unit test' % base_name)
test_builders = []
for suites_name, suites in config['unittest_suites']:
test_builders.extend(generateTestBuilderNames('%s test' % base_name, suites_name, suites))
unittestPrettyNames[platform] = '%s test' % base_name
triggeredUnittestBuilders.append(('%s-%s-unittest' % (name, platform), test_builders, config.get('enable_merging', True)))
# Optimized unittest builds
if pf.get('enable_opt_unittests'):
test_builders = []
for suites_name, suites in config['unittest_suites']:
unittestPrettyNames[platform] = '%s opt test' % base_name
test_builders.extend(generateTestBuilderNames('%s opt test' % base_name, suites_name, suites))
triggeredUnittestBuilders.append(('%s-%s-opt-unittest' % (name, platform), test_builders, config.get('enable_merging', True)))
if config['enable_codecoverage'] and platform in ('linux',):
coverageBuilders.append('%s code coverage' % base_name)
if config.get('enable_blocklist_update', False) and platform in ('linux',):
weeklyBuilders.append('%s blocklist update' % base_name)
if pf.get('enable_xulrunner', config['enable_xulrunner']):
xulrunnerNightlyBuilders.append('%s xulrunner' % base_name)
if config['enable_weekly_bundle']:
weeklyBuilders.append('%s hg bundle' % name)
logUploadCmd = makeLogUploadCommand(name, config, is_try=config.get('enable_try'),
is_shadow=bool(name=='shadow-central'), platform_prop='stage_platform',product_prop='product')
# this comment is for grepping! SubprocessLogHandler
branchObjects['status'].append(QueuedCommandHandler(
logUploadCmd,
QueueDir.getQueue('commands'),
builders=builders + unittestBuilders + debugBuilders + periodicPgoBuilders,
))
if nightlyBuilders:
branchObjects['status'].append(QueuedCommandHandler(
logUploadCmd + ['--nightly'],
QueueDir.getQueue('commands'),
builders=nightlyBuilders,
))
# Currently, each branch goes to a different tree
# If this changes in the future this may have to be
# moved out of the loop
if not config.get('disable_tinderbox_mail'):
branchObjects['status'].append(TinderboxMailNotifier(
fromaddr="mozilla2.buildbot@build.mozilla.org",
tree=config['tinderbox_tree'],
extraRecipients=["tinderbox-daemon@tinderbox.mozilla.org"],
relayhost="mail.build.mozilla.org",
builders=builders + nightlyBuilders + unittestBuilders + debugBuilders,
logCompression="gzip",
errorparser="unittest"
))
# XULRunner builds
branchObjects['status'].append(TinderboxMailNotifier(
fromaddr="mozilla2.buildbot@build.mozilla.org",
tree=config['xulrunner_tinderbox_tree'],
extraRecipients=["tinderbox-daemon@tinderbox.mozilla.org"],
relayhost="mail.build.mozilla.org",
builders=xulrunnerNightlyBuilders,
logCompression="gzip"
))
# Code coverage builds go to a different tree
branchObjects['status'].append(TinderboxMailNotifier(
fromaddr="mozilla2.buildbot@build.mozilla.org",
tree=config['weekly_tinderbox_tree'],
extraRecipients=["tinderbox-daemon@tinderbox.mozilla.org"],
relayhost="mail.build.mozilla.org",
builders=coverageBuilders,
logCompression="gzip",
errorparser="unittest"
))
# Try Server notifier
if config.get('enable_mail_notifier'):
packageUrl = config['package_url']
packageDir = config['package_dir']
if config.get('notify_real_author'):
extraRecipients = []
sendToInterestedUsers = True
else:
extraRecipients = config['email_override']
sendToInterestedUsers = False
# This notifies users as soon as we receive their push, and will let them
# know where to find builds/logs
branchObjects['status'].append(ChangeNotifier(
fromaddr="tryserver@build.mozilla.org",
lookup=MercurialEmailLookup(),
relayhost="mail.build.mozilla.org",
sendToInterestedUsers=sendToInterestedUsers,
extraRecipients=extraRecipients,
branches=[config['repo_path']],
messageFormatter=lambda c: buildTryChangeMessage(c,
'/'.join([packageUrl, packageDir])),
))
if config['enable_l10n']:
l10n_builders = []
for b in l10nBuilders:
if config['enable_l10n_onchange']:
l10n_builders.append(l10nBuilders[b]['l10n_builder'])
l10n_builders.append(l10nNightlyBuilders['%s nightly' % b]['l10n_builder'])
l10n_binaryURL = config['enUS_binaryURL']
if l10n_binaryURL.endswith('/'):
l10n_binaryURL = l10n_binaryURL[:-1]
l10n_binaryURL += "-l10n"
nomergeBuilders.extend(l10n_builders)
branchObjects['status'].append(TinderboxMailNotifier(
fromaddr="bootstrap@mozilla.com",
tree=config['l10n_tinderbox_tree'],
extraRecipients=["tinderbox-daemon@tinderbox.mozilla.org"],
relayhost="mail.build.mozilla.org",
logCompression="gzip",
builders=l10n_builders,
binaryURL=l10n_binaryURL
))
# We only want the builds from the specified builders
# since their builds have a build property called "locale"
branchObjects['status'].append(TinderboxMailNotifier(
fromaddr="bootstrap@mozilla.com",
tree=WithProperties(config['l10n_tinderbox_tree'] + "-%(locale)s"),
extraRecipients=["tinderbox-daemon@tinderbox.mozilla.org"],
relayhost="mail.build.mozilla.org",
logCompression="gzip",
builders=l10n_builders,
binaryURL=l10n_binaryURL
))
# Log uploads for dep l10n repacks
branchObjects['status'].append(QueuedCommandHandler(
logUploadCmd + ['--l10n'],
QueueDir.getQueue('commands'),
builders=[l10nBuilders[b]['l10n_builder'] for b in l10nBuilders],
))
# and for nightly repacks
branchObjects['status'].append(QueuedCommandHandler(
logUploadCmd + ['--l10n', '--nightly'],
QueueDir.getQueue('commands'),
builders=[l10nNightlyBuilders['%s nightly' % b]['l10n_builder'] for b in l10nBuilders]
))
# Skip https repos until bug 592060 is fixed and we have a https-capable HgPoller
if config['hgurl'].startswith('https:'):
pass
else:
if config.get('enable_try', False):
tipsOnly = True
# Pay attention to all branches for pushes to try
repo_branch = None
else:
tipsOnly = True
# Other branches should only pay attention to the default branch
repo_branch = "default"
branchObjects['change_source'].append(HgPoller(
hgURL=config['hgurl'],
branch=config['repo_path'],
tipsOnly=tipsOnly,
repo_branch=repo_branch,
pollInterval=pollInterval,
))
if config['enable_l10n'] and config['enable_l10n_onchange']:
hg_all_locales_poller = HgAllLocalesPoller(hgURL = config['hgurl'],
repositoryIndex = config['l10n_repo_path'],
pollInterval=l10nPollInterval)
hg_all_locales_poller.parallelRequests = 1
branchObjects['change_source'].append(hg_all_locales_poller)
# schedulers
# this one gets triggered by the HG Poller
# for Try we have a custom scheduler that can accept a function to read commit comments
# in order to know what to schedule
extra_args = {}
if config.get('enable_try'):
scheduler_class = makePropertiesScheduler(BuilderChooserScheduler, [buildUIDSchedFunc])
extra_args['chooserFunc'] = tryChooser
extra_args['numberOfBuildsToTrigger'] = 1
extra_args['prettyNames'] = prettyNames
else:
scheduler_class = makePropertiesScheduler(Scheduler, [buildIDSchedFunc, buildUIDSchedFunc])
if not config.get('enable_merging', True):
nomergeBuilders.extend(builders + unittestBuilders + debugBuilders)
nomergeBuilders.extend(periodicPgoBuilders) # these should never, ever merge
extra_args['treeStableTimer'] = None
branchObjects['schedulers'].append(scheduler_class(
name=name,
branch=config['repo_path'],
builderNames=builders + unittestBuilders + debugBuilders,
fileIsImportant=lambda c: isHgPollerTriggered(c, config['hgurl']) and shouldBuild(c),
**extra_args
))
if config['enable_l10n']:
l10n_builders = []
for b in l10nBuilders:
l10n_builders.append(l10nBuilders[b]['l10n_builder'])
# This L10n scheduler triggers only the builders of its own branch
branchObjects['schedulers'].append(Scheduler(
name="%s l10n" % name,
branch=config['l10n_repo_path'],
treeStableTimer=None,
builderNames=l10n_builders,
fileIsImportant=lambda c: isImportantL10nFile(c, config['l10n_modules']),
properties={
'app': 'browser',
'en_revision': 'default',
'l10n_revision': 'default',
}
))
for scheduler_branch, test_builders, merge in triggeredUnittestBuilders:
scheduler_name = scheduler_branch
for test in test_builders:
unittestSuites.append(test.split(' ')[-1])
if not merge:
nomergeBuilders.extend(test_builders)
extra_args = {}
if config.get('enable_try'):
scheduler_class = BuilderChooserScheduler
extra_args['chooserFunc'] = tryChooser
extra_args['numberOfBuildsToTrigger'] = 1
extra_args['prettyNames'] = prettyNames
extra_args['unittestSuites'] = unittestSuites
extra_args['unittestPrettyNames'] = unittestPrettyNames
else:
scheduler_class = Scheduler
branchObjects['schedulers'].append(scheduler_class(
name=scheduler_name,
branch=scheduler_branch,
builderNames=test_builders,
treeStableTimer=None,
**extra_args
))
if not config.get('disable_tinderbox_mail'):
branchObjects['status'].append(TinderboxMailNotifier(
fromaddr="mozilla2.buildbot@build.mozilla.org",
tree=config['packaged_unittest_tinderbox_tree'],
extraRecipients=["tinderbox-daemon@tinderbox.mozilla.org"],
relayhost="mail.build.mozilla.org",
builders=test_builders,
logCompression="gzip",
errorparser="unittest"
))
branchObjects['status'].append(QueuedCommandHandler(
logUploadCmd,
QueueDir.getQueue('commands'),
builders=test_builders,
))
# Now, setup the nightly en-US schedulers and maybe,
# their downstream l10n ones
if nightlyBuilders or xulrunnerNightlyBuilders:
goodFunc = lastGoodFunc(
branch=config['repo_path'],
builderNames=builders,
triggerBuildIfNoChanges=False,
l10nBranch=config.get('l10n_repo_path')
)
nightly_scheduler = makePropertiesScheduler(
SpecificNightly,
[buildIDSchedFunc, buildUIDSchedFunc])(
ssFunc=goodFunc,
name="%s nightly" % name,
branch=config['repo_path'],
# bug 482123 - keep the minute to avoid problems with DST
# changes
hour=config['start_hour'], minute=config['start_minute'],
builderNames=nightlyBuilders + xulrunnerNightlyBuilders,
)
branchObjects['schedulers'].append(nightly_scheduler)
if len(periodicPgoBuilders) > 0:
pgo_scheduler = makePropertiesScheduler(
Nightly,
[buildIDSchedFunc, buildUIDSchedFunc])(
name="%s pgo" % name,
branch=config['repo_path'],
builderNames=periodicPgoBuilders,
hour=range(0,24,config['periodic_pgo_interval']),
)
branchObjects['schedulers'].append(pgo_scheduler)
for builder in nightlyBuilders + xulrunnerNightlyBuilders:
if config['enable_l10n'] and \
config['enable_nightly'] and builder in l10nNightlyBuilders:
l10n_builder = l10nNightlyBuilders[builder]['l10n_builder']
platform = l10nNightlyBuilders[builder]['platform']
branchObjects['schedulers'].append(TriggerableL10n(
name=l10n_builder,
platform=platform,
builderNames=[l10n_builder],
branch=config['repo_path'],
baseTag='default',
localesURL=config.get('localesURL', None)
))
weekly_scheduler = Nightly(
name='weekly-%s' % name,
branch=config['repo_path'],
dayOfWeek=5, # Saturday
hour=[3], minute=[02],
builderNames=coverageBuilders + weeklyBuilders,
)
branchObjects['schedulers'].append(weekly_scheduler)
# We iterate throught the platforms a second time, so we need
# to ensure that disabled platforms aren't configured the second time
enabled_platforms = []
for platform in sorted(config['platforms'].keys()):
pf = config['platforms'][platform]
if pf['stage_product'] in config['enabled_products']:
enabled_platforms.append(platform)
for platform in enabled_platforms:
# shorthand
pf = config['platforms'][platform]
# The stage platform needs to be used by the factory __init__ methods
# as well as the log handler status target. Instead of repurposing the
# platform property on each builder, we will create a new property
# on the needed builders
stage_platform = pf.get('stage_platform', platform)
uploadPackages = True
uploadSymbols = False
packageTests = False
talosMasters = pf['talos_masters']
unittestBranch = "%s-%s-opt-unittest" % (name, platform)
# Generate the PGO branch even if it isn't on for dep builds
# because we will still use it for nightlies... maybe
pgoUnittestBranch = "%s-%s-pgo-unittest" % (name, platform)
tinderboxBuildsDir = None
if platform.find('-debug') > -1:
# Some platforms can't run on the build host
leakTest = pf.get('enable_leaktests', True)
codesighs = False
if not pf.get('enable_unittests'):
uploadPackages = pf.get('packageTests', False)
else:
packageTests = True
talosMasters = None
# Platform already has the -debug suffix
unittestBranch = "%s-%s-unittest" % (name, platform)
tinderboxBuildsDir = "%s-%s" % (name, platform)
else:
if pf.get('enable_opt_unittests'):
packageTests=True
codesighs = pf.get('enable_codesighs', True)
leakTest = False
# Allow for test packages on platforms that can't be tested
# on the same master.
packageTests = pf.get('packageTests', packageTests)
if platform.find('win') > -1:
codesighs = False
doBuildAnalysis = pf.get('enable_build_analysis', False)
buildSpace = pf.get('build_space', config['default_build_space'])
l10nSpace = config['default_l10n_space']
clobberTime = pf.get('clobber_time', config['default_clobber_time'])
mochitestLeakThreshold = pf.get('mochitest_leak_threshold', None)
crashtestLeakThreshold = pf.get('crashtest_leak_threshold', None)
checkTest = pf.get('enable_checktests', False)
valgrindCheck = pf.get('enable_valgrind_checktests', False)
extra_args = {}