forked from mozilla-releng/build-buildbotcustom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.py
2830 lines (2522 loc) · 124 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
try:
import json
assert json # pyflakes
except:
import simplejson as json
import collections
import random
import re
import sys
import os
from copy import deepcopy
import inspect
from functools import wraps
from twisted.python import log
from buildbot.scheduler import Nightly, Scheduler, Triggerable
from buildbot.schedulers.filter import ChangeFilter
from buildbot.steps.shell import WithProperties
from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, EXCEPTION, RETRY
from buildbot.util import now
import buildbotcustom.common
import buildbotcustom.changes.hgpoller
import buildbotcustom.process.factory
import buildbotcustom.l10n
import buildbotcustom.scheduler
import buildbotcustom.status.mail
import buildbotcustom.status.generators
import buildbotcustom.status.queued_command
import buildbotcustom.misc_scheduler
import build.paths
import mozilla_buildtools.queuedir
reload(buildbotcustom.common)
reload(buildbotcustom.changes.hgpoller)
reload(buildbotcustom.process.factory)
reload(buildbotcustom.l10n)
reload(buildbotcustom.scheduler)
reload(buildbotcustom.status.mail)
reload(buildbotcustom.status.generators)
reload(buildbotcustom.misc_scheduler)
reload(build.paths)
reload(mozilla_buildtools.queuedir)
from buildbotcustom.common import normalizeName
from buildbotcustom.changes.hgpoller import HgPoller, HgAllLocalesPoller
from buildbotcustom.process.factory import NightlyBuildFactory, \
NightlyRepackFactory, \
TryBuildFactory, ScriptFactory, SigningScriptFactory, rc_eval_func
from buildbotcustom.scheduler import BuilderChooserScheduler, \
PersistentScheduler, makePropertiesScheduler, SpecificNightly, EveryNthScheduler
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, lastRevFunc
# 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
# 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
_product_excludes = {
'__all': [
re.compile('^CLOBBER'),
re.compile('/docs/'),
re.compile('^tools/mercurial/hgsetup/'),
],
'firefox': [
re.compile('android'),
re.compile('gonk'),
re.compile('^b2g/'),
re.compile('^build/mobile'),
re.compile('^mobile/'),
re.compile('^testing/mochitest/runrobocop.py')
],
'mobile': [
re.compile('gonk'),
re.compile('^b2g/'),
re.compile('^accessible/public/ia2'),
re.compile('^accessible/public/msaa'),
re.compile('^accessible/src/mac'),
re.compile('^accessible/src/windows'),
re.compile('^browser/'),
re.compile('^build/macosx'),
re.compile('^build/package/mac_osx'),
re.compile('^build/win32'),
re.compile('^build/win64'),
re.compile('^devtools/client'),
re.compile('^toolkit/system/osxproxy'),
re.compile('^toolkit/system/windowsproxy'),
re.compile('^toolkit/themes/osx'),
re.compile('^webapprt/win'),
re.compile('^webapprt/mac'),
re.compile('^widget/cocoa'),
re.compile('^widget/windows'),
re.compile('^xulrunner/')
],
'thunderbird': [
re.compile("^im/"),
re.compile("^suite/")
],
}
def isImportantForProduct(change, product):
"""Handles product specific handling of important files"""
# For each file, check each product's exclude list
# If a file is not excluded, then the change is important
# If all files are excluded, then the change is not important
# As long as hgpoller's 'overflow' marker isn't excluded, it will cause all
# products to build
excludes = _product_excludes.get(product, []) + _product_excludes.get('__all', [])
for f in change.files:
excluded = any(e.search(f) for e in excludes)
if not excluded:
log.msg("%s important for %s because of %s" % (
change.revision, product, f))
return True
# Everything was excluded
log.msg("%s not important for %s because all files were excluded" %
(change.revision, product))
return False
def makeImportantFunc(hgurl, product):
def isImportant(c):
if not isHgPollerTriggered(c, hgurl):
return False
if not shouldBuild(c):
return False
# No product is specified, so all changes are important
if product is None:
return True
return isImportantForProduct(c, product)
return isImportant
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 changeContainsScriptRepoRevision(change, revision):
script_repo_revision = change.properties.getProperty("script_repo_revision")
if script_repo_revision == revision:
log.msg("%s revision matches script_repo_revision %s" % (revision, script_repo_revision))
return True
log.msg("%s revision does not match script_repo_revision %s" % (revision, script_repo_revision))
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' %
(name_prefix, suites_name, i + 1))
else:
test_builders.append('%s %s' % (name_prefix, suites_name))
return test_builders
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]
# Skip non-successful builds
if build.getResults() != 0:
continue
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 safeNextSlave(func):
"""Wrapper around nextSlave functions that catch exceptions , log them, and
choose a random slave instead"""
@wraps(func)
def _nextSlave(builder, available_slaves):
try:
return func(builder, available_slaves)
except Exception:
log.msg("Error choosing next slave for builder '%s', choosing"
" randomly instead" % builder.name)
log.err()
if available_slaves:
return random.choice(available_slaves)
return None
return _nextSlave
def _get_pending(builder):
"""Returns the pending build requests for this builder"""
frame = inspect.currentframe()
# Walk up the stack until we find 't', a db transaction object. It allows
# us to make synchronous calls to the db from this thread.
# We need to commit this horrible crime because
# a) we're running in a thread
# b) so we can't use the db's existing sync query methods since they use a
# db connection created in another thread
# c) nor can we use deferreds (threads and deferreds don't play well
# together)
# d) there's no other way to get a db connection
while 't' not in frame.f_locals:
frame = frame.f_back
t = frame.f_locals['t']
del frame
return builder._getBuildable(t, None)
def is_spot(name):
return "-spot-" in name
def _classifyAWSSlaves(slaves):
"""
Partitions slaves into three groups: inhouse, ondemand, spot according to
their name. Returns three lists:
inhouse, ondemand, spot
"""
inhouse = []
ondemand = []
spot = []
for s in slaves:
if not s.slave:
continue
name = s.slave.slavename
if is_spot(name):
spot.append(s)
elif 'ec2' in name:
ondemand.append(s)
else:
inhouse.append(s)
return inhouse, ondemand, spot
def _nextAWSSlave(aws_wait=None, recentSort=False):
"""
Returns a nextSlave function that pick the next available slave, with some
special consideration for AWS instances:
- If the request is very new, wait for an inhouse instance to pick it
up. Set aws_wait to the number of seconds to wait before using an AWS
instance. Set to None to disable this behaviour.
- Otherwise give the job to a spot instance
If recentSort is True then pick slaves that most recently did this type of
build. Otherwise pick randomly.
"""
log.msg("nextAWSSlave: start")
if recentSort:
def sorter(slaves, builder):
if not slaves:
return None
return sorted(slaves, _recentSort(builder))[-1]
else:
def sorter(slaves, builder):
if not slaves:
return None
return random.choice(slaves)
def _nextSlave(builder, available_slaves):
# Partition the slaves into 3 groups:
# - inhouse slaves
# - ondemand slaves
# - spot slaves
# We always prefer to run on inhouse. We'll wait up to aws_wait
# seconds for one to show up!
# Easy! If there are no available slaves, don't return any!
if not available_slaves:
return None
inhouse, ondemand, spot = _classifyAWSSlaves(available_slaves)
# Always prefer inhouse slaves
if inhouse:
log.msg("nextAWSSlave: Choosing inhouse because it's the best!")
return sorter(inhouse, builder)
# We need to look at our build requests if we need to know # of
# retries, or if we're going to be waiting for an inhouse slave to come
# online.
if aws_wait or spot:
requests = _get_pending(builder)
if requests:
oldestRequestTime = sorted(requests, key=lambda r:
r.submittedAt)[0].submittedAt
else:
oldestRequestTime = 0
if aws_wait and now() - oldestRequestTime < aws_wait:
log.msg("nextAWSSlave: Waiting for inhouse slaves to show up")
return None
if spot:
log.msg("nextAWSSlave: Choosing spot since there aren't any retries")
return sorter(spot, builder)
elif ondemand:
log.msg("nextAWSSlave: Choosing ondemand since there aren't any spot available")
return sorter(ondemand, builder)
else:
log.msg("nextAWSSlave: No slaves - returning None")
return None
return _nextSlave
_nextAWSSlave_sort = safeNextSlave(_nextAWSSlave(aws_wait=0, recentSort=True))
_nextAWSSlave_nowait = safeNextSlave(_nextAWSSlave())
@safeNextSlave
def _nextSlave(builder, available_slaves):
# Choose the slave that was most recently on this builder
if available_slaves:
return sorted(available_slaves, _recentSort(builder))[-1]
else:
return None
def _nextIdleSlave(nReserved):
"""Return a nextSlave function that will only return a slave to run a build
if there are at least nReserved slaves available."""
@safeNextSlave
def _nextslave(builder, available_slaves):
if len(available_slaves) <= nReserved:
return None
return sorted(available_slaves, _recentSort(builder))[-1]
return _nextslave
# Globals for mergeRequests
nomergeBuilders = set()
# Default to max of 3 merged requests.
builderMergeLimits = collections.defaultdict(lambda: 3)
# For tracking state in mergeRequests below
_mergeCount = 0
_mergeId = None
def mergeRequests(builder, req1, req2):
"""
Returns True if req1 and req2 are mergeable requests, False otherwise.
This is called by buildbot to determine if pairs of buildrequests can be
merged together for a build.
Args:
builder (buildbot builder object): which builder is being considered
req1 (buildbot request object): first request being considered.
This stays constant for a given build being constructed.
req2 (buildbot request object): second request being considered.
This changes as the buildbot master considers all pending requests
for the build.
"""
global _mergeCount, _mergeId
# If the requests are fundamentally unmergeable, get that done first
if not req1.canBeMergedWith(req2):
# The requests are inherently unmergeable; e.g. on different branches
# Don't log this; it would be spammy
return False
log.msg("mergeRequests: considering %s %s %s" % (builder.name, req1.id, req2.id))
# Merging is disallowed on these builders
if builder.name in nomergeBuilders:
log.msg("mergeRequests: in nomergeBuilders; returning False")
return False
if 'Self-serve' in req1.reason or 'Self-serve' in req2.reason:
# A build was explicitly requested on this revision, so don't coalesce
# it
log.msg("mergeRequests: self-serve; returning False")
return False
# Disable merging of nightly jobs
if req1.properties.getProperty('nightly_build', False) or req2.properties.getProperty('nightly_build', False):
log.msg("mergeRequests: nightly_build; returning False")
return False
# We're merging a different request now; reset the state
# This works because buildbot calls this function with the same req1 for
# all pending requests for the builder, only req2 varies between calls.
# Once req1 changes we know we're in the middle of creating a different
# build.
if req1.id != _mergeId:
# Start counting at 1 here, since if we're being called, we've already
# got 2 requests we're considering merging. If we pa
_mergeCount = 1
_mergeId = req1.id
log.msg("mergeRequests: different r1 id; resetting state")
if _mergeCount >= builderMergeLimits[builder.name]:
# This request has already been merged with too many requests
log.msg("mergeRequests: %s: exceeded limit (%i)" %
(builder.name, builderMergeLimits[builder.name]))
return False
log.msg("mergeRequests: %s merging %i %i" % (builder.name, req1.id, req2.id))
_mergeCount += 1
return True
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 makeMHFactory(config, pf, mh_cfg=None, extra_args=None, **kwargs):
factory_class = ScriptFactory
if not mh_cfg:
mh_cfg = pf['mozharness_config']
if 'signingServers' in kwargs:
if kwargs['signingServers'] is not None:
factory_class = SigningScriptFactory
else:
del kwargs['signingServers']
scriptRepo = config.get('mozharness_repo_url',
'%s%s' % (config['hgurl'], config['mozharness_repo_path']))
script_repo_cache = None
if config.get('use_mozharness_repo_cache'): # branch supports it
script_repo_cache = mh_cfg.get('mozharness_repo_cache',
pf.get('mozharness_repo_cache'))
if 'env' in pf:
kwargs['env'] = pf['env'].copy()
if not extra_args:
extra_args = mh_cfg.get('extra_args')
factory = factory_class(
scriptRepo=scriptRepo,
interpreter=mh_cfg.get('mozharness_python', pf.get('mozharness_python')),
scriptName=mh_cfg['script_name'],
reboot_command=mh_cfg.get('reboot_command', pf.get('reboot_command')),
extra_args=extra_args,
script_timeout=mh_cfg.get('script_timeout', pf.get('timeout', 3600)),
script_maxtime=mh_cfg.get('script_maxtime', pf.get('maxTime', 4 * 3600)),
script_repo_cache=script_repo_cache,
script_repo_manifest=config.get('script_repo_manifest'),
relengapi_archiver_repo_path=config.get('mozharness_archiver_repo_path'),
relengapi_archiver_rev=config.get('mozharness_archiver_rev'),
tools_repo_cache=mh_cfg.get('tools_repo_cache',
pf.get('tools_repo_cache')),
**kwargs
)
return factory
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,
mozharness_suite_config=None,
mozharness_repo=None, mozharness_tag='production',
script_repo_manifest=None, relengapi_archiver_repo_path=None,
relengapi_archiver_rev=None, is_debug=None):
# We only support mozharness stuff now!
assert mozharness
builders = []
if slaves is None:
slavenames = config['platforms'][platform]['slaves']
else:
slavenames = slaves
if not category:
category = branch_name
branchProperty = branch_name
properties = {'branch': branchProperty, 'platform': platform,
'slavebuilddir': 'test', 'stage_platform': stagePlatform,
'product': stageProduct, 'repo_path': config['repo_path'],
'moz_repo_path': config.get('moz_repo_path', '')}
# suites is a dict!
if mozharness_suite_config is None:
mozharness_suite_config = {}
extra_args = []
if mozharness_suite_config.get('config_files'):
extra_args.extend(['--cfg', ','.join(mozharness_suite_config['config_files'])])
extra_args.extend(mozharness_suite_config.get('extra_args', suites.get('extra_args', [])))
if is_debug is True:
extra_args.extend(
mozharness_suite_config.get(
'debug_extra_args',
suites.get('debug_extra_args', [])
)
)
elif is_debug is False:
extra_args.extend(
mozharness_suite_config.get(
'opt_extra_args',
suites.get('opt_extra_args', [])
)
)
if mozharness_suite_config.get('blob_upload'):
extra_args.extend(['--blob-upload-branch', branch_name])
if mozharness_suite_config.get('download_symbols'):
extra_args.extend(['--download-symbols', mozharness_suite_config['download_symbols']])
reboot_command = mozharness_suite_config.get(
'reboot_command', suites.get('reboot_command', None))
hg_bin = mozharness_suite_config.get(
'hg_bin', suites.get('hg_bin', 'hg'))
properties['script_repo_revision'] = mozharness_tag
factory = ScriptFactory(
interpreter=mozharness_python,
scriptRepo=mozharness_repo,
scriptName=suites['script_path'],
hg_bin=hg_bin,
extra_args=extra_args,
use_credentials_file=True,
script_maxtime=suites.get('script_maxtime', 7200),
script_timeout=suites.get('timeout', 1800),
script_repo_manifest=script_repo_manifest,
relengapi_archiver_repo_path=relengapi_archiver_repo_path,
relengapi_archiver_rev=relengapi_archiver_rev,
reboot_command=reboot_command,
platform=platform,
env=mozharness_suite_config.get('env', {}),
log_eval_func=rc_eval_func({
0: SUCCESS,
1: WARNINGS,
2: FAILURE,
3: EXCEPTION,
4: 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,
'nextSlave': _nextAWSSlave_nowait,
}
builders.append(builder)
return builders
def generateMozharnessTalosBuilder(platform, mozharness_repo, script_path,
hg_bin, mozharness_python,
reboot_command, extra_args=None,
script_timeout=3600,
script_maxtime=7200,
script_repo_manifest=None,
relengapi_archiver_repo_path=None,
relengapi_archiver_rev=None):
if extra_args is None:
extra_args = []
return ScriptFactory(
interpreter=mozharness_python,
scriptRepo=mozharness_repo,
scriptName=script_path,
hg_bin=hg_bin,
extra_args=extra_args,
use_credentials_file=True,
script_timeout=script_timeout,
script_maxtime=script_maxtime,
script_repo_manifest=script_repo_manifest,
relengapi_archiver_repo_path=relengapi_archiver_repo_path,
relengapi_archiver_rev=relengapi_archiver_rev,
reboot_command=reboot_command,
platform=platform,
log_eval_func=rc_eval_func({
0: SUCCESS,
1: WARNINGS,
2: FAILURE,
3: EXCEPTION,
4: RETRY,
}),
)
def generateUnittestBuilders(platform_name, branch, test_type,
create_pgo_builders, **test_builder_kwargs):
builders = []
builders.extend(generateTestBuilder(**test_builder_kwargs))
if create_pgo_builders and test_type == 'opt':
pgo_builder_kwargs = test_builder_kwargs.copy()
pgo_builder_kwargs['name_prefix'] = "%s %s pgo test" % (platform_name, branch)
pgo_builder_kwargs['build_dir_prefix'] += '_pgo'
pgo_builder_kwargs['stagePlatform'] += '-pgo'
builders.extend(generateTestBuilder(**pgo_builder_kwargs))
return builders
def generateChunkedUnittestBuilders(total_chunks, *args, **kwargs):
if not total_chunks:
return generateUnittestBuilders(
*args, **kwargs
)
builders = []
for i in range(1, total_chunks + 1):
kwargs_copy = kwargs.copy()
kwargs_copy['suites_name'] = '%s-%d' % (kwargs_copy['suites_name'], i)
chunk_args = [
'--total-chunks', str(total_chunks),
'--this-chunk', str(i)
]
if 'extra_args' in kwargs_copy['mozharness_suite_config']:
# Not used any more
assert False
elif 'extra_args' in kwargs_copy['suites']:
kwargs_copy['suites'] = deepcopy(kwargs['suites'])
kwargs_copy['suites']['extra_args'].extend(chunk_args)
# We should have only one set of --this-chunk and --total-chunks here
assert kwargs_copy['suites']['extra_args'].count('--this-chunk') == 1
assert kwargs_copy['suites']['extra_args'].count('--total-chunks') == 1
else:
# Not used any more
assert False
builders.extend(generateUnittestBuilders(
*args, **kwargs_copy
))
return builders
def generateDesktopMozharnessBuilders(name, platform, config, secrets,
l10nNightlyBuilders, builds_created):
desktop_mh_builders = []
pf = config['platforms'][platform]
mh_cfg = pf['mozharness_desktop_build']
base_extra_args = mh_cfg.get('extra_args', [])
# let's grab the extra args that are defined at misc level
branch_and_pool_args = []
branch_and_pool_args.extend(['--branch', name])
if config.get('staging'):
branch_and_pool_args.extend(['--build-pool', 'staging'])
else: # this is production
branch_and_pool_args.extend(['--build-pool', 'production'])
base_extra_args.extend(branch_and_pool_args)
base_builder_dir = '%s-%s' % (name, platform)
# let's assign next_slave here so we only have to change it in
# this location for mozharness builds if we swap it out again.
next_slave = _nextAWSSlave_sort
return_codes_func = rc_eval_func({
0: SUCCESS,
1: WARNINGS,
2: FAILURE,
3: EXCEPTION,
4: RETRY,
})
# look mom, no buildbot properties needed for desktop
# mozharness builds!!
mh_build_properties = {
# our buildbot master.cfg requires us to at least have
# these but mozharness doesn't need them
'branch': name,
'platform': platform,
'product': pf['stage_product'],
'repo_path': config['repo_path'],
'script_repo_revision': config["mozharness_tag"],
}
dep_signing_servers = secrets.get(pf.get('dep_signing_servers'))
nightly_signing_servers = secrets.get(pf.get('nightly_signing_servers'))
# grab the l10n schedulers that nightlies will trigger (if any)
triggered_nightly_schedulers = []
if config.get("enable_triggered_nightly_scheduler", True):
if is_l10n_with_mh(config, platform):
scheduler_name = mh_l10n_scheduler_name(config, platform)
triggered_nightly_schedulers.append(scheduler_name)
elif (config['enable_l10n'] and platform in config['l10n_platforms'] and
'%s nightly' % pf['base_name'] in l10nNightlyBuilders):
base_name = '%s nightly' % pf['base_name']
# see bug 1150015
l10n_builder = l10nNightlyBuilders[base_name]['l10n_builder']
assert(isinstance(l10n_builder, str))
triggered_nightly_schedulers.append(l10n_builder)
elif config['enable_l10n'] and pf.get('is_mobile_l10n') and pf.get('l10n_chunks'):
triggered_nightly_schedulers.append('%s-%s-l10n' % (name, platform))
# if we do a generic dep build
if pf.get('enable_dep', True) or pf.get('enable_periodic', False):
factory = makeMHFactory(config, pf, mh_cfg=mh_cfg,
extra_args=base_extra_args,
signingServers=dep_signing_servers,
use_credentials_file=True,
log_eval_func=return_codes_func)
generic_builder = {
'name': '%s build' % pf['base_name'],
'builddir': base_builder_dir,
'slavebuilddir': normalizeName(base_builder_dir),
'slavenames': pf['slaves'],
'nextSlave': next_slave,
'factory': factory,
'category': name,
'properties': mh_build_properties.copy(),
}
desktop_mh_builders.append(generic_builder)
builds_created['done_generic_build'] = True
# if do nightly:
if config['enable_nightly'] and pf.get('enable_nightly', True):
nightly_extra_args = base_extra_args + config['mozharness_desktop_extra_options']['nightly']
# include use_credentials_file for balrog step
nightly_factory = makeMHFactory(config, pf, mh_cfg=mh_cfg,
extra_args=nightly_extra_args,
signingServers=nightly_signing_servers,
triggered_schedulers=triggered_nightly_schedulers,
copy_properties=['buildid', 'builduid', 'packageUrl'],
use_credentials_file=True,
log_eval_func=return_codes_func)
nightly_builder = {
'name': '%s nightly' % pf['base_name'],
'builddir': '%s-nightly' % base_builder_dir,
'slavebuilddir': normalizeName('%s-nightly' % base_builder_dir),
'slavenames': pf['slaves'],
'nextSlave': next_slave,
'factory': nightly_factory,
'category': name,
'properties': mh_build_properties.copy(),
}
desktop_mh_builders.append(nightly_builder)
builds_created['done_nightly_build'] = True
if is_l10n_with_mh(config, platform):
l10n_builders = mh_l10n_builders(config, platform, name, secrets,
is_nightly=True)
desktop_mh_builders.extend(l10n_builders)
builds_created['done_l10n_repacks'] = True
# Handle l10n for try
elif config.get('enable_try') and config['enable_l10n']:
if is_l10n_with_mh(config, platform):
l10n_builders = mh_l10n_builders(config, platform, name, secrets,
is_nightly=False)
desktop_mh_builders.extend(l10n_builders)
builds_created['done_l10n_repacks'] = True
# if we_do_pgo:
if (config['pgo_strategy'] in ('periodic', 'try') and
platform in config['pgo_platforms']):
pgo_extra_args = base_extra_args + config['mozharness_desktop_extra_options']['pgo']
pgo_factory = makeMHFactory(
config, pf, mh_cfg=mh_cfg, extra_args=pgo_extra_args,
use_credentials_file=True,
signingServers=dep_signing_servers, log_eval_func=return_codes_func
)
pgo_builder = {
'name': '%s pgo-build' % pf['base_name'],
'builddir': '%s-pgo' % base_builder_dir,
'slavebuilddir': normalizeName('%s-pgo' % base_builder_dir),
'slavenames': pf['slaves'],
'factory': pgo_factory,
'category': name,
'nextSlave': next_slave,
'properties': mh_build_properties.copy(),
}
desktop_mh_builders.append(pgo_builder)
builds_created['done_pgo_build'] = True
# finally let's return which builders we did so we know what's left to do!
return desktop_mh_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, 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 = {}
# List of all the per-checkin builders
builders = []
# Which builders should we consider when looking at per-checkin results and
# determining what revision we should do a nightly build on
buildersForNightly = []
buildersByProduct = {}
nightlyBuilders = []
periodicBuilders = []
weeklyBuilders = []
# prettyNames is a mapping to pass to the try_parser for validation
PRETTY_NAME = '%(basename)s %(trystatus)sbuild'
NAME = '%(basename)s build'
prettyNames = {}
# 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', 'try', 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']
if 'mozharness_config' in pf:
# this is a spider build. mozharness desktop builds use same
# scheduling/naming logic as the non mozharness equivalent.
if pf.get('enable_dep', True):
buildername = '%s_dep' % pf['base_name']
builders.append(buildername)
if pf.get('consider_for_nightly', True):
buildersForNightly.append(buildername)
buildersByProduct.setdefault(
pf['stage_product'], []).append(buildername)
prettyNames[platform] = buildername
if not pf.get('try_by_default', True):
prettyNames[platform] += " try-nondefault"
elif pf.get('enable_periodic', False):
buildername = "%s_periodic" % pf['base_name']
periodicBuilders.append(buildername)
if pf.get('consider_for_nightly', True):
buildersForNightly.append(buildername)
if not pf.get('try_by_default', True):
prettyNames[platform] += " try-nondefault"
if pf.get('enable_nightly'):
buildername = '%s_nightly' % pf['base_name']
nightlyBuilders.append(buildername)
continue
values = {'basename': base_name,
'trystatus': '' if pf.get('try_by_default', True) else 'try-nondefault ',
}
pretty_name = PRETTY_NAME % values
buildername = NAME % values
if pf.get('enable_dep', True):
builders.append(buildername)
if pf.get('consider_for_nightly', True):
buildersForNightly.append(buildername)
buildersByProduct.setdefault(
pf['stage_product'], []).append(buildername)
prettyNames[platform] = pretty_name
elif pf.get('enable_periodic', False):
periodicBuilders.append(buildername)
if pf.get('consider_for_nightly', True):
buildersForNightly.append(buildername)
# Check if branch wants nightly builds
if config['enable_nightly']:
if 'enable_nightly' in pf:
do_nightly = pf['enable_nightly']
else:
do_nightly = True
else:
do_nightly = False
# Check if platform as a PGO builder
if config['pgo_strategy'] in ('periodic',) and platform in config['pgo_platforms']:
periodicBuilders.append('%s pgo-build' % pf['base_name'])
elif config['pgo_strategy'] in ('try',) and platform in config['pgo_platforms']:
builders.append('%s pgo-build' % pf['base_name'])
buildersByProduct.setdefault(pf['stage_product'], []).append(
'%s pgo-build' % pf['base_name'])
if do_nightly:
builder = '%s nightly' % base_name
nightlyBuilders.append(builder)
if config["enable_l10n"]:
l10n_builder = '%s %s %s l10n nightly' % (
pf['product_name'].capitalize(), name, platform
)
# Fill the l10nNightly dict
# trying to do repacks with mozharness
if is_l10n_with_mh(config, platform):
# we need this later...
builder_names = mh_l10n_builder_names(config, platform, branch=name,
is_nightly=True)
scheduler_name = mh_l10n_scheduler_name(config, platform)
l10nNightlyBuilders[builder] = {}
l10nNightlyBuilders[builder]['l10n_builder'] = builder_names
l10nNightlyBuilders[builder]['platform'] = platform
l10nNightlyBuilders[builder]['scheduler_name'] = scheduler_name
l10nNightlyBuilders[builder]['l10n_repacks_with_mh'] = True
else:
# no repacks with mozharness, old style repacks
if config['enable_l10n'] and platform in config['l10n_platforms']:
l10nNightlyBuilders[builder] = {}
l10nNightlyBuilders[builder]['tree'] = config['l10n_tree']
l10nNightlyBuilders[builder]['l10n_builder'] = l10n_builder
l10nNightlyBuilders[builder]['platform'] = platform
if platform in ('linux64',):
if config.get('enable_blocklist_update', False) or \
config.get('enable_hsts_update', False) or \
config.get('enable_hpkp_update', False):
weeklyBuilders.append('%s periodic file update' % base_name)
# 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