OLD | NEW |
1 # -*- python -*- | 1 # -*- python -*- |
2 # ex: set syntax=python: | 2 # ex: set syntax=python: |
3 | 3 |
4 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 4 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 import os | 8 import os |
9 import random | 9 import random |
10 import shutil | 10 import shutil |
11 import subprocess | 11 import subprocess |
12 import sys | 12 import sys |
13 import tempfile | 13 import tempfile |
14 | 14 |
15 # These modules come from scripts/master, which must be in the PYTHONPATH. | 15 # These modules come from scripts/master, which must be in the PYTHONPATH. |
16 from common import cros_chromite | 16 from common import cros_chromite |
| 17 from master import gitiles_poller |
17 from master import master_utils | 18 from master import master_utils |
18 from master import slaves_list | 19 from master import slaves_list |
19 from master.cros_try_job_git import CrOSTryJobGit | 20 from master.cros_try_job_git import CrOSTryJobGit |
20 from master.factory import chromeos_factory | 21 from master.factory import annotator_factory, chromeos_factory |
21 | 22 |
22 from buildbot.buildslave import BuildSlave | 23 from buildbot.buildslave import BuildSlave |
23 from buildbot.changes.gitpoller import GitPoller | |
24 from buildbot.process.properties import WithProperties | 24 from buildbot.process.properties import WithProperties |
25 | 25 |
26 # These modules come from scripts/common, which must be in the PYTHONPATH. | 26 # These modules come from scripts/common, which must be in the PYTHONPATH. |
27 import chromiumos_tryserver_util | 27 import chromiumos_tryserver_util |
28 import config | 28 import config |
29 import master_site_config | 29 import master_site_config |
30 | 30 |
31 ActiveMaster = master_site_config.ChromiumOSTryServer | 31 ActiveMaster = master_site_config.ChromiumOSTryServer |
32 | 32 |
33 # This is the dictionary that the buildmaster pays attention to. We also use | 33 # This is the dictionary that the buildmaster pays attention to. We also use |
34 # a shorter alias to save typing. | 34 # a shorter alias to save typing. |
35 c = BuildmasterConfig = {} | 35 c = BuildmasterConfig = {} |
36 | 36 |
37 config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host) | 37 config.DatabaseSetup(c, require_dbconfig=ActiveMaster.is_production_host) |
38 | 38 |
39 ####### CHANGESOURCES | 39 ####### CHANGESOURCES |
40 | 40 |
41 # The gitpoller doesn't play well with SSH-AGENT, so for test masters running | |
42 # on a developer's machine, you need to set up a password-less ssh key. | |
43 c['change_source'] = [] | 41 c['change_source'] = [] |
44 c['change_source'].append(GitPoller( | 42 c['change_source'].append(gitiles_poller.GitilesPoller( |
45 repourl=ActiveMaster.repo_url_ext, | 43 ActiveMaster.repo_url_ext, |
46 branch='master' if ActiveMaster.is_production_host else 'test', | 44 branches=['master'], |
47 workdir=tempfile.mkdtemp(prefix='gitpoller_ext'), | 45 )) |
48 pollinterval=10)) | 46 gitiles_comparator = c['change_source'][-1].comparator |
49 | 47 |
50 if ActiveMaster.repo_url_int: | 48 if ActiveMaster.repo_url_int: |
51 c['change_source'].append(GitPoller( | 49 c['change_source'].append(gitiles_poller.GitilesPoller( |
52 repourl=ActiveMaster.repo_url_int, | 50 ActiveMaster.repo_url_int, |
53 branch='master' if ActiveMaster.is_production_host else 'test', | 51 branches=['master'], |
54 workdir=tempfile.mkdtemp(prefix='gitpoller_int'), | 52 comparator=gitiles_comparator, |
55 pollinterval=10)) | 53 )) |
56 | 54 |
57 # Avoid merging requests. | 55 # Avoid merging requests. |
58 c['mergeRequests'] = lambda *_: False | 56 c['mergeRequests'] = lambda *_: False |
59 | 57 |
60 | 58 |
61 ####### JOB AND BUILDER SELECTION ALGORITHM | 59 ####### JOB AND BUILDER SELECTION ALGORITHM |
62 | 60 |
63 DEFINED_SLAVES = slaves_list.SlavesList('slaves.cfg', 'ChromiumOSTryServer') | 61 DEFINED_SLAVES = slaves_list.SlavesList('slaves.cfg', 'ChromiumOSTryServer') |
64 | 62 |
65 # We isolate testing slaves here - we can force their use through the try job. | 63 # We isolate testing slaves here - we can force their use through the try job. |
66 testing_slave_pool = chromiumos_tryserver_util.TestingSlavePool( | 64 testing_slave_pool = chromiumos_tryserver_util.TestingSlavePool( |
67 [slave['hostname'] | 65 [slave['hostname'] |
68 for slave in DEFINED_SLAVES.GetSlaves() | 66 for slave in DEFINED_SLAVES.GetSlaves() |
69 if slave['version'] == 'testing']) | 67 if slave['version'] == 'testing']) |
70 | 68 |
71 ####### BUILDERS | 69 ####### BUILDERS |
72 | 70 |
73 c['builders'] = [] | 71 c['builders'] = [] |
74 | 72 |
75 # ---------------------------------------------------------------------------- | 73 # ---------------------------------------------------------------------------- |
76 # BUILDER DEFINITIONS | 74 # BUILDER DEFINITIONS |
77 | 75 |
78 nextSlaveAndBuild = chromiumos_tryserver_util.NextSlaveAndBuild( | 76 nextSlaveAndBuild = chromiumos_tryserver_util.NextSlaveAndBuild( |
79 testing_slave_pool=testing_slave_pool) | 77 testing_slave_pool=testing_slave_pool) |
80 | 78 |
| 79 # Annotator factory object. |
| 80 factory_obj = annotator_factory.AnnotatorFactory( |
| 81 active_master=ActiveMaster) |
| 82 |
81 # The 'builders' list defines the Builders. Each one is configured with a | 83 # The 'builders' list defines the Builders. Each one is configured with a |
82 # dictionary, using the following keys: | 84 # dictionary, using the following keys: |
83 # name (required): the name used to describe this bilder | 85 # name (required): the name used to describe this bilder |
84 # category (required): it is not used in the normal 'buildbot' meaning. It is | 86 # category (required): it is not used in the normal 'buildbot' meaning. It is |
85 # used by gatekeeper to determine which steps it should | 87 # used by gatekeeper to determine which steps it should |
86 # look for to close the tree. | 88 # look for to close the tree. |
87 def _GetCBuildbotBuilder(name, category, params=None, clobber=False): | 89 def _GetCBuildbotBuilder(name, category): |
88 | 90 builder = { |
89 factory = chromeos_factory.CbuildbotFactory( | 91 'name': name, |
90 params=params, | |
91 trybot=True, | |
92 clobber=clobber).get_factory() | |
93 | |
94 return { | |
95 'builddir': name.replace(' ', '-'), | 92 'builddir': name.replace(' ', '-'), |
96 'category': category, | 93 'category': category, |
97 'factory': factory, | 94 'factory': chromeos_factory.ChromiteRecipeFactory( |
98 'name': name, | 95 factory_obj, 'cros/cbuildbot_tryjob'), |
99 'slavenames': DEFINED_SLAVES.GetSlavesName(builder=name), | 96 'slavenames': DEFINED_SLAVES.GetSlavesName(builder=name), |
100 'nextSlaveAndBuild' : nextSlaveAndBuild, | 97 'nextSlaveAndBuild' : nextSlaveAndBuild, |
101 } | 98 } |
102 | 99 return builder |
103 | 100 |
104 def _GetCategory(cfg): | 101 def _GetCategory(cfg): |
105 if cfg in ('etc',): | 102 if cfg in ('etc',): |
106 return '1etc full|info' | 103 return '1etc full|info' |
107 elif cfg in chromiumos_tryserver_util.precq_builders: | 104 elif cfg in chromiumos_tryserver_util.precq_builders: |
108 return '2precq full|info' | 105 return '2precq full|info' |
109 elif cfg in chromiumos_tryserver_util.cbb_builders: | 106 elif cfg in chromiumos_tryserver_util.cbb_builders: |
110 return '3general full|info' | 107 return '3general full|info' |
111 else: | 108 else: |
112 raise TypeError("Unhandled builder type: %s" % (type(cfg).__name__)) | 109 raise TypeError("Unhandled builder type: %s" % (type(cfg).__name__)) |
113 | 110 |
114 | 111 |
115 def _GetBuilder(cfg): | 112 def _GetBuilder(cfg): |
116 builder = _GetCBuildbotBuilder( | 113 builder = _GetCBuildbotBuilder( |
117 cfg, | 114 cfg, |
118 _GetCategory(cfg), | 115 _GetCategory(cfg), |
119 params=WithProperties('%(chromeos_config:-)s'), | |
120 ) | 116 ) |
121 return builder | 117 return builder |
122 | 118 |
123 | 119 |
124 def _GetEtcBuilder(): | 120 def _GetEtcBuilder(): |
125 name = 'etc' | 121 name = 'etc' |
126 cbuilddir = 'etc_%(branch)s' % { | 122 cbuilddir = 'etc_%(branch)s' % { |
127 'branch': 'master', | 123 'branch': 'master', |
128 } | 124 } |
129 | 125 |
130 builder = _GetCBuildbotBuilder( | 126 builder = _GetCBuildbotBuilder( |
131 name, | 127 name, |
132 _GetCategory(name), | 128 _GetCategory(name), |
133 params=WithProperties('%(chromeos_config:-)s'), | |
134 clobber=True, | |
135 ) | 129 ) |
136 return builder | 130 return builder |
137 | 131 |
138 | 132 |
139 # Add 'etc' builder to try arbitrary configs. | 133 # Add 'etc' builder to try arbitrary configs. |
140 c['builders'] += [_GetEtcBuilder()] | 134 c['builders'] += [_GetEtcBuilder()] |
141 | 135 |
142 # Add Try builders for every current 'cbuildbot' config. | 136 # Add Try builders for every current 'cbuildbot' config. |
143 c['builders'] += [_GetBuilder(cfg) | 137 c['builders'] += [_GetBuilder(cfg) |
144 for cfg in sorted(chromiumos_tryserver_util.cbb_builders)] | 138 for cfg in sorted(chromiumos_tryserver_util.cbb_builders)] |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 builders=[], | 195 builders=[], |
202 relayhost=config.Master.smtp, | 196 relayhost=config.Master.smtp, |
203 lookup=master_utils.UsersAreEmails())) | 197 lookup=master_utils.UsersAreEmails())) |
204 | 198 |
205 # Try job result emails. | 199 # Try job result emails. |
206 from master.try_mail_notifier import TryMailNotifier | 200 from master.try_mail_notifier import TryMailNotifier |
207 | 201 |
208 def _GetInfo(info, build): | 202 def _GetInfo(info, build): |
209 """Get the subject of a trybot email.""" | 203 """Get the subject of a trybot email.""" |
210 info = info.copy() | 204 info = info.copy() |
211 info['chromeos_config'] = build.getProperties().getProperty('chromeos_config', | 205 info['cbb_config'] = build.getProperties().getProperty('cbb_config', |
212 info['builder']) | 206 info['builder']) |
213 return info | 207 return info |
214 | 208 |
215 c['status'].append(TryMailNotifier( | 209 c['status'].append(TryMailNotifier( |
216 reply_to=ActiveMaster.reply_to, | 210 reply_to=ActiveMaster.reply_to, |
217 failure_message='TRY FAILED', | 211 failure_message='TRY FAILED', |
218 footer=email_footer, | 212 footer=email_footer, |
219 fromaddr=ActiveMaster.from_address, | 213 fromaddr=ActiveMaster.from_address, |
220 subject="try %(result)s for %(reason)s on %(chromeos_config)s", | 214 subject="try %(result)s for %(reason)s on %(cbb_config)s", |
221 mode='all', | 215 mode='all', |
222 get_info=_GetInfo, | 216 get_info=_GetInfo, |
223 relayhost=smtp_host, | 217 relayhost=smtp_host, |
224 lookup=master_utils.UsersAreEmails())) | 218 lookup=master_utils.UsersAreEmails())) |
225 | 219 |
226 # Do it at the end to override values set by AutoSetupMaster, the default is | 220 # Do it at the end to override values set by AutoSetupMaster, the default is |
227 # too low. Must keep at least a few days worth of builds. | 221 # too low. Must keep at least a few days worth of builds. |
228 c['buildHorizon'] = 3000 | 222 c['buildHorizon'] = 3000 |
229 c['logHorizon'] = 3000 | 223 c['logHorizon'] = 3000 |
230 # Must be at least 2x the number of slaves. | 224 # Must be at least 2x the number of slaves. |
231 c['eventHorizon'] = 200 | 225 c['eventHorizon'] = 200 |
232 | 226 |
233 if not ActiveMaster.is_production_host: | 227 if not ActiveMaster.is_production_host: |
234 # Dump the current configuration. | 228 # Dump the current configuration. |
235 master_utils.DumpSetup(c) | 229 master_utils.DumpSetup(c) |
OLD | NEW |