Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 # vim: set ft=python: | 4 # vim: set ft=python: |
| 5 | 5 |
| 6 import collections | |
| 7 | |
| 6 from buildbot.changes.gitpoller import GitPoller | 8 from buildbot.changes.gitpoller import GitPoller |
| 7 | 9 from buildbot.scheduler import Scheduler |
| 10 from buildbot.scheduler import Triggerable | |
| 11 from common import chromium_utils | |
| 8 from master import build_utils | 12 from master import build_utils |
| 9 from master import master_config | 13 from master import master_config |
| 10 from master import master_utils | 14 from master import master_utils |
| 11 from master import recipe_master_helper | |
| 12 from master import slaves_list | 15 from master import slaves_list |
| 13 from master.factory import annotator_factory | 16 from master.factory import annotator_factory |
| 14 | 17 |
| 15 import config | 18 import config |
| 16 import master_site_config | 19 import master_site_config |
| 17 | 20 |
| 18 | 21 |
| 22 def AddSchedulersAndTriggers(buildmaster_config=None, | |
| 23 builders=None, | |
| 24 scheduler_name=None, | |
| 25 branch=None): | |
|
iannucci
2014/07/21 17:31:03
buildmaster_config and builders shouldn't default
borenet
2014/07/21 18:04:31
Yeah, and I don't know what happens when the sched
| |
| 26 """Clone of recipe_master_helper.AddSchedulersAndTriggers which separates | |
| 27 builders and buildslaves more cleanly. | |
| 28 """ | |
| 29 c = buildmaster_config | |
| 30 polling_builders = [] | |
| 31 # Maps the parent builder to a set of the names of the builders it triggers. | |
| 32 trigger_map = collections.defaultdict(list) | |
| 33 # Maps the name of the parent builder to the (synthesized) name of its | |
| 34 # trigger, wrapped in a list. | |
| 35 trigger_name_map = {} | |
| 36 next_group_id = 0 | |
| 37 for builder in builders: | |
| 38 builder_name = builder['name'] | |
| 39 parent_builder = builder.get('triggered_by') | |
| 40 if parent_builder is not None: | |
| 41 for maybe_parent in builders: | |
|
iannucci
2014/07/21 17:31:03
instead of looping a second time, I would add all
borenet
2014/07/21 18:04:31
Did something similar but used difference so I cou
| |
| 42 if maybe_parent['name'] == parent_builder: | |
| 43 break | |
| 44 else: | |
| 45 raise Exception('Could not find parent builder %s for builder %s' % | |
| 46 (parent_builder, builder_name)) | |
| 47 trigger_map[parent_builder].append(builder_name) | |
| 48 if parent_builder not in trigger_name_map: | |
| 49 trigger_name_map[parent_builder] = 'trigger_group_%d' % next_group_id | |
| 50 next_group_id += 1 | |
| 51 else: | |
| 52 polling_builders.append(builder_name) | |
| 53 s = Scheduler(name=scheduler_name, | |
| 54 branch=branch, | |
| 55 treeStableTimer=60, | |
| 56 builderNames=polling_builders) | |
| 57 c['schedulers'] = [s] | |
| 58 for name, builders in trigger_map.iteritems(): | |
| 59 c['schedulers'].append(Triggerable(name=trigger_name_map[name], | |
| 60 builderNames=builders)) | |
| 61 return trigger_name_map | |
| 62 | |
| 63 | |
| 64 def AddRecipeBasedBuilders(buildmaster_config=None, | |
| 65 builders=None, | |
| 66 annotator=None, | |
| 67 trigger_name_map=None, | |
| 68 default_auto_reboot=False): | |
| 69 """Clone of recipe_master_helper.AddRecipeBasedBuilders which separates | |
| 70 builders and buildslaves more cleanly. | |
| 71 """ | |
| 72 builders_list = [] | |
| 73 for builder in builders: | |
| 74 if 'recipe' in builder: | |
|
iannucci
2014/07/21 17:31:03
if it's not, that should be an error, right?
borenet
2014/07/21 18:04:31
In the next CL, I'll remove the 'if' and just defa
| |
| 75 name = builder['name'] | |
| 76 build_config = 'Release' if 'Release' in name else 'Debug' | |
|
iannucci
2014/07/21 17:31:03
hm, sneaky. If we were making the names have seman
borenet
2014/07/21 18:04:31
Yeah, this is bad. Skia's bots currently do exactl
| |
| 77 factory_properties = { | |
| 78 'test_results_server': 'test-results.appspot.com', | |
| 79 'generate_gtest_json': True, | |
| 80 'build_config': build_config, | |
| 81 } | |
| 82 if 'perf_id' in builder: | |
| 83 factory_properties['show_perf_results'] = True | |
| 84 factory_properties['perf_id'] = builder['perf_id'] | |
| 85 builder_dict = { | |
| 86 'name': name, | |
| 87 'factory': annotator.BaseFactory( | |
| 88 builder['recipe'], | |
| 89 factory_properties, | |
| 90 [trigger_name_map[name]] if name in trigger_name_map else None), | |
| 91 'gatekeeper': builder.get('gatekeeper_categories', ''), | |
| 92 } | |
| 93 builder_dict['auto_reboot'] = builder.get('auto_reboot', False) | |
| 94 builders_list.append(builder_dict) | |
| 95 buildmaster_config['builders'] = builders_list | |
| 96 | |
| 97 | |
| 19 ActiveMaster = master_site_config.Skia | 98 ActiveMaster = master_site_config.Skia |
| 20 | 99 |
| 21 c = BuildmasterConfig = {} | 100 c = BuildmasterConfig = {} |
| 22 | 101 |
| 23 config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host) | 102 config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host) |
| 24 | 103 |
| 25 ####### CHANGESOURCES | 104 ####### CHANGESOURCES |
| 26 | 105 |
| 27 # Polls config.Master.trunk_url for changes | 106 # Polls config.Master.trunk_url for changes |
| 28 poller = GitPoller( | 107 poller = GitPoller( |
| 29 repourl=ActiveMaster.repo_url, | 108 repourl=ActiveMaster.repo_url, |
| 30 branch='master', | 109 branch='master', |
| 31 pollinterval=10, | 110 pollinterval=10, |
| 32 revlinktmpl='https://skia.googlesource.com/skia/+/%s') | 111 revlinktmpl='https://skia.googlesource.com/skia/+/%s') |
| 33 | 112 |
| 34 | |
| 35 c['change_source'] = [poller] | 113 c['change_source'] = [poller] |
| 36 | 114 |
| 37 | |
| 38 ####### SLAVES | 115 ####### SLAVES |
| 39 | 116 |
| 40 # Load the slave list. We need some information from it in order to | 117 # Load the slave list. We need some information from it in order to |
| 41 # produce the builders. | 118 # produce the builders. |
| 42 slaves = slaves_list.SlavesList('slaves.cfg', 'Skia') | 119 slaves = slaves_list.SlavesList('slaves.cfg', ActiveMaster.project_name) |
| 120 | |
| 121 ####### BUILDERS | |
| 122 | |
| 123 # Load the builders list. | |
| 124 builders = chromium_utils.ParsePythonCfg('builders.cfg')['builders'] | |
| 43 | 125 |
| 44 ####### SCHEDULERS | 126 ####### SCHEDULERS |
| 45 | 127 |
| 46 ## configure the Schedulers | 128 # Configure the Schedulers. |
| 129 trigger_name_map = AddSchedulersAndTriggers(buildmaster_config=c, | |
| 130 builders=builders, | |
| 131 scheduler_name='skia', | |
| 132 branch='master') | |
| 47 | 133 |
| 48 # Main scheduler for all changes in trunk. | 134 ####### FACTORIES |
| 49 | |
| 50 trigger_name_map = recipe_master_helper.AddSchedulersAndTriggers( | |
| 51 buildmaster_config=c, slave_list=slaves, scheduler_name='skia', | |
| 52 branch='master') | |
| 53 | |
| 54 ####### BUILDERS | |
| 55 | |
| 56 builders = [] | |
| 57 | |
| 58 # ---------------------------------------------------------------------------- | |
| 59 # FACTORIES | |
| 60 | 135 |
| 61 m_annotator = annotator_factory.AnnotatorFactory() | 136 m_annotator = annotator_factory.AnnotatorFactory() |
| 62 | 137 AddRecipeBasedBuilders(c, builders, m_annotator, trigger_name_map) |
| 63 recipe_master_helper.AddRecipeBasedBuilders( | |
| 64 c, slaves, m_annotator, trigger_name_map) | |
| 65 | 138 |
| 66 # Associate the slaves to the manual builders. The configuration is in | 139 # Associate the slaves to the manual builders. The configuration is in |
| 67 # slaves.cfg. | 140 # slaves.cfg. |
| 68 for builder in c['builders']: | 141 for builder in c['builders']: |
| 69 builder['slavenames'] = slaves.GetSlavesName(builder=builder['name']) | 142 builder['slavenames'] = slaves.GetSlavesName(builder=builder['name']) |
| 70 | 143 |
| 71 ####### BUILDSLAVES | 144 ####### BUILDSLAVES |
| 72 | 145 |
| 73 # The 'slaves' list defines the set of allowable buildslaves. List all the | 146 # The 'slaves' list defines the set of allowable buildslaves. List all the |
| 74 # slaves registered to a builder. Remove dupes. | 147 # slaves registered to a builder. Remove dupes. |
| 75 c['slaves'] = master_utils.AutoSetupSlaves(c['builders'], | 148 c['slaves'] = master_utils.AutoSetupSlaves(c['builders'], |
| 76 config.Master.GetBotPassword()) | 149 config.Master.GetBotPassword()) |
| 77 | |
| 78 master_utils.VerifySetup(c, slaves) | 150 master_utils.VerifySetup(c, slaves) |
| 79 | 151 |
| 80 ####### STATUS TARGETS | 152 ####### STATUS TARGETS |
| 81 | 153 |
| 82 c['buildbotURL'] = ActiveMaster.buildbot_url | 154 c['buildbotURL'] = ActiveMaster.buildbot_url |
| 83 | 155 |
| 84 # Adds common status and tools to this master. | 156 # Adds common status and tools to this master. |
| 85 master_utils.AutoSetupMaster(c, ActiveMaster, | 157 master_utils.AutoSetupMaster(c, ActiveMaster, |
| 86 public_html='../master.chromium/public_html', | 158 public_html='../master.chromium/public_html', |
| 87 templates=['../master.chromium/templates'], | 159 templates=['../master.chromium/templates'], |
| 88 enable_http_status_push=ActiveMaster.is_production_host, | 160 enable_http_status_push=ActiveMaster.is_production_host, |
| 89 order_console_by_time=True) | 161 order_console_by_time=True) |
| OLD | NEW |