| 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, |
| 23 builders, |
| 24 scheduler_name, |
| 25 branch=None): |
| 26 """Clone of recipe_master_helper.AddSchedulersAndTriggers which separates |
| 27 builders and buildslaves more cleanly. |
| 28 """ |
| 29 c = buildmaster_config |
| 30 polling_builders = [] |
| 31 parent_builders = set() |
| 32 # Maps the parent builder to a set of the names of the builders it triggers. |
| 33 trigger_map = collections.defaultdict(list) |
| 34 # Maps the name of the parent builder to the (synthesized) name of its |
| 35 # trigger, wrapped in a list. |
| 36 trigger_name_map = {} |
| 37 next_group_id = 0 |
| 38 for builder in builders: |
| 39 builder_name = builder['name'] |
| 40 parent_builder = builder.get('triggered_by') |
| 41 if parent_builder is not None: |
| 42 parent_builders.add(parent_builder) |
| 43 trigger_map[parent_builder].append(builder_name) |
| 44 if parent_builder not in trigger_name_map: |
| 45 trigger_name_map[parent_builder] = 'trigger_group_%d' % next_group_id |
| 46 next_group_id += 1 |
| 47 else: |
| 48 polling_builders.append(builder_name) |
| 49 # Verify that all parent builders exist. |
| 50 nonexistent_parents = parent_builders - set(polling_builders) |
| 51 if nonexistent_parents: |
| 52 raise Exception('Could not find parent builders: %s' % |
| 53 ', '.join(nonexistent_parents)) |
| 54 s = Scheduler(name=scheduler_name, |
| 55 branch=branch, |
| 56 treeStableTimer=60, |
| 57 builderNames=polling_builders) |
| 58 c['schedulers'] = [s] |
| 59 for name, builders in trigger_map.iteritems(): |
| 60 c['schedulers'].append(Triggerable(name=trigger_name_map[name], |
| 61 builderNames=builders)) |
| 62 return trigger_name_map |
| 63 |
| 64 |
| 65 def AddRecipeBasedBuilders(buildmaster_config, |
| 66 builders, |
| 67 annotator, |
| 68 trigger_name_map, |
| 69 default_auto_reboot=False): |
| 70 """Clone of recipe_master_helper.AddRecipeBasedBuilders which separates |
| 71 builders and buildslaves more cleanly. |
| 72 """ |
| 73 builders_list = [] |
| 74 for builder in builders: |
| 75 if 'recipe' in builder: |
| 76 name = builder['name'] |
| 77 build_config = 'Release' if 'Release' in name else 'Debug' |
| 78 factory_properties = { |
| 79 'test_results_server': 'test-results.appspot.com', |
| 80 'generate_gtest_json': True, |
| 81 'build_config': build_config, |
| 82 } |
| 83 if 'perf_id' in builder: |
| 84 factory_properties['show_perf_results'] = True |
| 85 factory_properties['perf_id'] = builder['perf_id'] |
| 86 builder_dict = { |
| 87 'name': name, |
| 88 'factory': annotator.BaseFactory( |
| 89 builder['recipe'], |
| 90 factory_properties, |
| 91 [trigger_name_map[name]] if name in trigger_name_map else None), |
| 92 'gatekeeper': builder.get('gatekeeper_categories', ''), |
| 93 } |
| 94 builder_dict['auto_reboot'] = builder.get('auto_reboot', False) |
| 95 builders_list.append(builder_dict) |
| 96 buildmaster_config['builders'] = builders_list |
| 97 |
| 98 |
| 19 ActiveMaster = master_site_config.Skia | 99 ActiveMaster = master_site_config.Skia |
| 20 | 100 |
| 21 c = BuildmasterConfig = {} | 101 c = BuildmasterConfig = {} |
| 22 | 102 |
| 23 config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host) | 103 config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host) |
| 24 | 104 |
| 25 ####### CHANGESOURCES | 105 ####### CHANGESOURCES |
| 26 | 106 |
| 27 # Polls config.Master.trunk_url for changes | 107 # Polls config.Master.trunk_url for changes |
| 28 poller = GitPoller( | 108 poller = GitPoller( |
| 29 repourl=ActiveMaster.repo_url, | 109 repourl=ActiveMaster.repo_url, |
| 30 branch='master', | 110 branch='master', |
| 31 pollinterval=10, | 111 pollinterval=10, |
| 32 revlinktmpl='https://skia.googlesource.com/skia/+/%s') | 112 revlinktmpl='https://skia.googlesource.com/skia/+/%s') |
| 33 | 113 |
| 34 | |
| 35 c['change_source'] = [poller] | 114 c['change_source'] = [poller] |
| 36 | 115 |
| 37 | |
| 38 ####### SLAVES | 116 ####### SLAVES |
| 39 | 117 |
| 40 # Load the slave list. We need some information from it in order to | 118 # Load the slave list. We need some information from it in order to |
| 41 # produce the builders. | 119 # produce the builders. |
| 42 slaves = slaves_list.SlavesList('slaves.cfg', 'Skia') | 120 slaves = slaves_list.SlavesList('slaves.cfg', ActiveMaster.project_name) |
| 121 |
| 122 ####### BUILDERS |
| 123 |
| 124 # Load the builders list. |
| 125 builders = chromium_utils.ParsePythonCfg('builders.cfg')['builders'] |
| 43 | 126 |
| 44 ####### SCHEDULERS | 127 ####### SCHEDULERS |
| 45 | 128 |
| 46 ## configure the Schedulers | 129 # Configure the Schedulers. |
| 130 trigger_name_map = AddSchedulersAndTriggers(buildmaster_config=c, |
| 131 builders=builders, |
| 132 scheduler_name='skia', |
| 133 branch='master') |
| 47 | 134 |
| 48 # Main scheduler for all changes in trunk. | 135 ####### 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 | 136 |
| 61 m_annotator = annotator_factory.AnnotatorFactory() | 137 m_annotator = annotator_factory.AnnotatorFactory() |
| 62 | 138 AddRecipeBasedBuilders(c, builders, m_annotator, trigger_name_map) |
| 63 recipe_master_helper.AddRecipeBasedBuilders( | |
| 64 c, slaves, m_annotator, trigger_name_map) | |
| 65 | 139 |
| 66 # Associate the slaves to the manual builders. The configuration is in | 140 # Associate the slaves to the manual builders. The configuration is in |
| 67 # slaves.cfg. | 141 # slaves.cfg. |
| 68 for builder in c['builders']: | 142 for builder in c['builders']: |
| 69 builder['slavenames'] = slaves.GetSlavesName(builder=builder['name']) | 143 builder['slavenames'] = slaves.GetSlavesName(builder=builder['name']) |
| 70 | 144 |
| 71 ####### BUILDSLAVES | 145 ####### BUILDSLAVES |
| 72 | 146 |
| 73 # The 'slaves' list defines the set of allowable buildslaves. List all the | 147 # The 'slaves' list defines the set of allowable buildslaves. List all the |
| 74 # slaves registered to a builder. Remove dupes. | 148 # slaves registered to a builder. Remove dupes. |
| 75 c['slaves'] = master_utils.AutoSetupSlaves(c['builders'], | 149 c['slaves'] = master_utils.AutoSetupSlaves(c['builders'], |
| 76 config.Master.GetBotPassword()) | 150 config.Master.GetBotPassword()) |
| 77 | |
| 78 master_utils.VerifySetup(c, slaves) | 151 master_utils.VerifySetup(c, slaves) |
| 79 | 152 |
| 80 ####### STATUS TARGETS | 153 ####### STATUS TARGETS |
| 81 | 154 |
| 82 c['buildbotURL'] = ActiveMaster.buildbot_url | 155 c['buildbotURL'] = ActiveMaster.buildbot_url |
| 83 | 156 |
| 84 # Adds common status and tools to this master. | 157 # Adds common status and tools to this master. |
| 85 master_utils.AutoSetupMaster(c, ActiveMaster, | 158 master_utils.AutoSetupMaster(c, ActiveMaster, |
| 86 public_html='../master.chromium/public_html', | 159 public_html='../master.chromium/public_html', |
| 87 templates=['../master.chromium/templates'], | 160 templates=['../master.chromium/templates'], |
| 88 enable_http_status_push=ActiveMaster.is_production_host, | 161 enable_http_status_push=ActiveMaster.is_production_host, |
| 89 order_console_by_time=True) | 162 order_console_by_time=True) |
| OLD | NEW |