Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 | 4 |
| 5 import ast | 5 import ast |
| 6 import os | 6 import os |
| 7 | 7 |
| 8 from buildbot.schedulers.basic import SingleBranchScheduler | 8 from buildbot.schedulers.basic import SingleBranchScheduler |
| 9 from buildbot.schedulers.timed import Nightly | 9 from buildbot.schedulers.timed import Nightly |
| 10 from buildbot.status.mail import MailNotifier | 10 from buildbot.status.mail import MailNotifier |
| 11 from buildbot import util | 11 from buildbot import util |
| 12 | 12 |
| 13 from config_bootstrap import Master | 13 from config_bootstrap import Master |
| 14 | 14 |
| 15 from common import chromium_utils | 15 from common import chromium_utils |
| 16 | 16 |
| 17 from master import gitiles_poller | 17 from master import gitiles_poller |
| 18 from master import master_utils | 18 from master import master_utils |
| 19 from master import repo_poller | |
| 19 from master import slaves_list | 20 from master import slaves_list |
| 20 from master.factory import annotator_factory | 21 from master.factory import annotator_factory |
| 21 | 22 |
| 22 | 23 |
| 23 def PopulateBuildmasterConfig(BuildmasterConfig, builders_path, | 24 def PopulateBuildmasterConfig(BuildmasterConfig, builders_path, |
| 24 active_master_cls): | 25 active_master_cls): |
| 25 """Read builders_path and populate a build master config dict.""" | 26 """Read builders_path and populate a build master config dict.""" |
| 26 builders = chromium_utils.ReadBuildersFile(builders_path) | 27 builders = chromium_utils.ReadBuildersFile(builders_path) |
| 27 _Populate(BuildmasterConfig, builders, active_master_cls) | 28 _Populate(BuildmasterConfig, builders, active_master_cls) |
| 28 | 29 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 if scheduler_name: | 131 if scheduler_name: |
| 131 if scheduler_name not in builders['schedulers']: | 132 if scheduler_name not in builders['schedulers']: |
| 132 raise ValueError('unknown scheduler "%s"' % scheduler_name) | 133 raise ValueError('unknown scheduler "%s"' % scheduler_name) |
| 133 scheduler_to_builders.setdefault(scheduler_name, []).append(builder_name) | 134 scheduler_to_builders.setdefault(scheduler_name, []).append(builder_name) |
| 134 | 135 |
| 135 schedulers = [] | 136 schedulers = [] |
| 136 for scheduler_name, scheduler_values in builders['schedulers'].items(): | 137 for scheduler_name, scheduler_values in builders['schedulers'].items(): |
| 137 scheduler_type = scheduler_values['type'] | 138 scheduler_type = scheduler_values['type'] |
| 138 builder_names = scheduler_to_builders[scheduler_name] | 139 builder_names = scheduler_to_builders[scheduler_name] |
| 139 | 140 |
| 140 if scheduler_type == 'git_poller': | 141 if scheduler_type in ('git_poller', 'repo_poller'): |
| 141 schedulers.append(SingleBranchScheduler( | 142 schedulers.append(SingleBranchScheduler( |
| 142 name=scheduler_name, | 143 name=scheduler_name, |
| 143 branch='master', | 144 branch='master', |
| 144 treeStableTimer=60, | 145 treeStableTimer=60, |
| 145 builderNames=builder_names)) | 146 builderNames=builder_names)) |
| 146 | 147 |
| 147 elif scheduler_type == 'cron': | 148 elif scheduler_type == 'cron': |
| 148 schedulers.append(Nightly( | 149 schedulers.append(Nightly( |
| 149 name=scheduler_name, | 150 name=scheduler_name, |
| 150 branch='master', | 151 branch='master', |
| 151 minute=scheduler_values['minute'], | 152 minute=scheduler_values['minute'], |
| 152 hour=scheduler_values['hour'], | 153 hour=scheduler_values['hour'], |
| 153 builderNames=builder_names)) | 154 builderNames=builder_names)) |
| 154 | 155 |
| 155 else: | 156 else: |
| 156 raise ValueError('unsupported scheduler type "%s"' % scheduler_type) | 157 raise ValueError('unsupported scheduler type "%s"' % scheduler_type) |
| 157 | 158 |
| 158 return schedulers | 159 return schedulers |
| 159 | 160 |
| 160 | 161 |
| 161 def _ComputeChangeSourceAndTagComparator(builders): | 162 def _ComputeChangeSourceAndTagComparator(builders): |
| 162 change_source = [] | 163 change_source = [] |
| 163 tag_comparator = None | 164 tag_comparator = None |
| 164 | 165 |
| 165 for url in sorted(set(v['git_repo_url'] for | 166 for url in sorted(set(v['git_repo_url'] for |
| 166 v in builders['schedulers'].values() | 167 v in builders['schedulers'].values() |
| 167 if v['type'] == 'git_poller')): | 168 if v['type'] == 'git_poller')): |
| 168 change_source.append(gitiles_poller.GitilesPoller(url)) | 169 change_source.append(gitiles_poller.GitilesPoller(url)) |
| 169 | 170 |
| 171 for scheduler_config in builders['schedulers'].values(): | |
| 172 if scheduler_config['type'] != 'repo_poller': | |
| 173 continue | |
| 174 | |
| 175 rev_link_template = scheduler_config.get('rev_link_template', None) | |
|
ghost stip (do not use)
2015/10/12 23:53:11
.get() already returns None, so you can just do re
danalbert
2015/10/13 00:29:52
Yeah, I just felt writing it was better to be expl
| |
| 176 branch = scheduler_config.get('branch', None) | |
|
ghost stip (do not use)
2015/10/12 23:53:11
same here, you can just do scheduler_config.get('b
| |
| 177 change_source.append(repo_poller.RepoPoller( | |
| 178 repo_url=scheduler_config['repo_url'], | |
| 179 manifest='manifest', | |
| 180 repo_branches=[branch], | |
|
ghost stip (do not use)
2015/10/12 23:53:11
what happens if repo_branches = [None] ? should we
danalbert
2015/10/13 00:29:51
It should actually be either `None` or `[]` rather
| |
| 181 pollInterval=300, | |
| 182 revlinktmpl=rev_link_template)) | |
| 183 | |
| 170 # We have to set the tag_comparator to something, but if we have multiple | 184 # We have to set the tag_comparator to something, but if we have multiple |
| 171 # repos, the tag_comparator will not work properly (it's meaningless). | 185 # repos, the tag_comparator will not work properly (it's meaningless). |
| 172 # It's not clear if there's a good answer to this. | 186 # It's not clear if there's a good answer to this. |
| 173 if change_source: | 187 if change_source: |
| 174 tag_comparator = change_source[0].comparator | 188 tag_comparator = change_source[0].comparator |
| 175 | 189 |
| 176 return change_source, tag_comparator | 190 return change_source, tag_comparator |
| OLD | NEW |