OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Set of utilities to build the chromium master.""" | 5 """Set of utilities to build the chromium master.""" |
6 | 6 |
7 import os | 7 import os |
8 | 8 |
9 from buildbot.steps import shell | 9 from buildbot.steps import shell |
10 from buildbot.interfaces import IRenderable | 10 from buildbot.interfaces import IRenderable |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 This class is a callable wrapper to annotator_factory.AnnotatorFactory's | 24 This class is a callable wrapper to annotator_factory.AnnotatorFactory's |
25 BaseFactory method. | 25 BaseFactory method. |
26 | 26 |
27 This class painfully avoids subclassing annotator_factory.AnnotatorFactory in | 27 This class painfully avoids subclassing annotator_factory.AnnotatorFactory in |
28 order to preserve its status as a terminal factory. | 28 order to preserve its status as a terminal factory. |
29 """ | 29 """ |
30 | 30 |
31 # The default Chromite recipe timeout. | 31 # The default Chromite recipe timeout. |
32 _CHROMITE_TIMEOUT = 9000 | 32 _CHROMITE_TIMEOUT = 9000 |
| 33 # The default maximum build time. |
| 34 _DEFAULT_MAX_TIME = 16 * 60 * 60 |
33 | 35 |
34 @classmethod | 36 @classmethod |
35 def __call__(cls, factory_obj, recipe, *args, **kwargs): | 37 def __call__(cls, factory_obj, recipe, *args, **kwargs): |
36 """Returns a factory object to use for Chromite annotator recipes. | 38 """Returns a factory object to use for Chromite annotator recipes. |
37 | 39 |
38 Args: | 40 Args: |
39 factory_obj (annotator_factory.AnnotatorFactory) The annotator factory. | 41 factory_obj (annotator_factory.AnnotatorFactory) The annotator factory. |
40 recipe: The name of the recipe to invoke. | 42 recipe: The name of the recipe to invoke. |
41 debug (bool): If True, override default debug logic. | 43 debug (bool): If True, override default debug logic. |
42 args, kwargs: Positional / keyword arguments (see | 44 args, kwargs: Positional / keyword arguments (see |
43 annotator_factory.AnnotatorFactory.BaseFactory). | 45 annotator_factory.AnnotatorFactory.BaseFactory). |
44 """ | 46 """ |
45 kwargs.setdefault('timeout', cls._CHROMITE_TIMEOUT) | 47 kwargs.setdefault('timeout', cls._CHROMITE_TIMEOUT) |
46 | 48 |
47 factory_properties = kwargs.setdefault('factory_properties', {}) | 49 factory_properties = kwargs.setdefault('factory_properties', {}) |
48 # Set the 'cbb_debug' property if we're not running in a production master. | 50 # Set the 'cbb_debug' property if we're not running in a production master. |
49 if kwargs.pop('debug', False): | 51 if kwargs.pop('debug', False): |
50 factory_properties['cbb_debug'] = True | 52 factory_properties['cbb_debug'] = True |
| 53 kwargs.setdefault('max_time', cls._DEFAULT_MAX_TIME) |
51 return factory_obj.BaseFactory(recipe, *args, **kwargs) | 54 return factory_obj.BaseFactory(recipe, *args, **kwargs) |
52 | 55 |
53 | 56 # Callable instance of '_ChromiteRecipeFactoryFunc'. |
54 # Callable instance of '_ChromiteFactoryFunc'. | |
55 ChromiteRecipeFactory = _ChromiteRecipeFactoryFunc() | 57 ChromiteRecipeFactory = _ChromiteRecipeFactoryFunc() |
56 | 58 |
57 | 59 |
58 class ChromiteFactory(object): | 60 class ChromiteFactory(object): |
59 """ | 61 """ |
60 Create a build factory that runs a chromite script. | 62 Create a build factory that runs a chromite script. |
61 | 63 |
62 This is designed mainly to utilize build scripts directly hosted in | 64 This is designed mainly to utilize build scripts directly hosted in |
63 chromite.git. | 65 chromite.git. |
64 | 66 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 class CbuildbotFactory(ChromiteFactory): | 214 class CbuildbotFactory(ChromiteFactory): |
213 """ | 215 """ |
214 Create a build factory that runs the cbuildbot script. | 216 Create a build factory that runs the cbuildbot script. |
215 | 217 |
216 Attributes: | 218 Attributes: |
217 params: space-delimited string of parameters to pass to the cbuildbot | 219 params: space-delimited string of parameters to pass to the cbuildbot |
218 command, or IRenderable. | 220 command, or IRenderable. |
219 script: name of the cbuildbot command. Default cbuildbot. | 221 script: name of the cbuildbot command. Default cbuildbot. |
220 buildroot: buildroot to set. Default is /b/cbuild. | 222 buildroot: buildroot to set. Default is /b/cbuild. |
221 dry_run: Don't push anything as we're running a test run. | 223 dry_run: Don't push anything as we're running a test run. |
222 trybot: Whether this is creating builders for the trybot waterfall. | |
223 chrome_root: The place to put or use the chrome source. | 224 chrome_root: The place to put or use the chrome source. |
224 pass_revision: to pass the chrome revision desired into the build. | 225 pass_revision: to pass the chrome revision desired into the build. |
225 legacy_chromite: If set, ask chromite to use an older cbuildbot directory. | 226 legacy_chromite: If set, ask chromite to use an older cbuildbot directory. |
226 clobber: If True, force a clobber. | 227 clobber: If True, force a clobber. |
227 *: anything else is passed to the base Chromite class. | 228 *: anything else is passed to the base Chromite class. |
228 """ | 229 """ |
229 | 230 |
230 def __init__(self, | 231 def __init__(self, |
231 params, | 232 params, |
232 script='cbuildbot', | 233 script='cbuildbot', |
233 buildroot='/b/cbuild', | 234 buildroot='/b/cbuild', |
234 dry_run=False, | 235 dry_run=False, |
235 trybot=False, | |
236 chrome_root=None, | 236 chrome_root=None, |
237 pass_revision=None, | 237 pass_revision=None, |
238 legacy_chromite=False, | 238 legacy_chromite=False, |
239 clobber=False, | 239 clobber=False, |
240 **kwargs): | 240 **kwargs): |
241 super(CbuildbotFactory, self).__init__(None, None, | 241 super(CbuildbotFactory, self).__init__(None, None, |
242 use_chromeos_factory=not pass_revision, **kwargs) | 242 use_chromeos_factory=not pass_revision, **kwargs) |
243 | 243 |
244 self.script = script | 244 self.script = script |
245 self.trybot = trybot | |
246 self.chrome_root = chrome_root | 245 self.chrome_root = chrome_root |
247 self.pass_revision = pass_revision | 246 self.pass_revision = pass_revision |
248 self.legacy_chromite = legacy_chromite | 247 self.legacy_chromite = legacy_chromite |
249 self.buildroot = buildroot | 248 self.buildroot = buildroot |
250 self.dry_run = dry_run | 249 self.dry_run = dry_run |
251 self.clobber = clobber | 250 self.clobber = clobber |
252 assert params | 251 assert params |
253 self.add_cbuildbot_step(params) | 252 self.add_cbuildbot_step(params) |
254 | 253 |
255 | 254 |
256 def add_cbuildbot_step(self, params): | 255 def add_cbuildbot_step(self, params): |
257 self.add_chromite_step(self.script, params, self.compute_buildbot_params(), | 256 self.add_chromite_step(self.script, params, self.compute_buildbot_params(), |
258 legacy=self.legacy_chromite) | 257 legacy=self.legacy_chromite) |
259 | 258 |
260 | 259 |
261 def compute_buildbot_params(self): | 260 def compute_buildbot_params(self): |
262 cmd = [WithProperties('--buildnumber=%(buildnumber)s'), | 261 cmd = [ |
263 ConditionalProperty( | 262 WithProperties('--buildnumber=%(buildnumber)s'), |
264 'buildroot', | 263 ConditionalProperty( |
265 WithProperties('--buildroot=%(buildroot)s'), | 264 'buildroot', |
266 '--buildroot=%s' % self.buildroot) | 265 WithProperties('--buildroot=%(buildroot)s'), |
267 ] | 266 '--buildroot=%s' % self.buildroot), |
| 267 '--buildbot', |
| 268 ] |
268 | 269 |
269 # Add '--master-build-id' flag when build ID property is present | 270 # Add '--master-build-id' flag when build ID property is present |
270 cmd.append( | 271 cmd.append( |
271 ConditionalProperty( | 272 ConditionalProperty( |
272 'master_build_id', | 273 'master_build_id', |
273 WithProperties('--master-build-id=%(master_build_id)s'), | 274 WithProperties('--master-build-id=%(master_build_id)s'), |
274 [], # Will be flattened to nothing. | 275 [], # Will be flattened to nothing. |
275 ) | 276 ) |
276 ) | 277 ) |
277 | 278 |
278 if self.trybot: | |
279 cmd.append(Property('extra_args')) | |
280 else: | |
281 cmd += ['--buildbot'] | |
282 | |
283 if self.dry_run: | 279 if self.dry_run: |
284 cmd += ['--debug'] | 280 cmd += ['--debug'] |
285 | 281 |
286 if self.chrome_root: | 282 if self.chrome_root: |
287 cmd.append('--chrome_root=%s' % self.chrome_root) | 283 cmd.append('--chrome_root=%s' % self.chrome_root) |
288 | 284 |
289 if self.pass_revision: | 285 if self.pass_revision: |
290 cmd.append(WithProperties('--chrome_version=%(revision)s')) | 286 cmd.append(WithProperties('--chrome_version=%(revision)s')) |
291 | 287 |
292 # Clobber if forced or if the 'clobber' property is set. | 288 # Clobber if forced or if the 'clobber' property is set. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 cmd.append(WithProperties('%s' + self.buildroot, 'clobber:+--clobber ')) | 343 cmd.append(WithProperties('%s' + self.buildroot, 'clobber:+--clobber ')) |
348 | 344 |
349 self.f_cbuild.addStep(chromium_step.AnnotatedCommand, | 345 self.f_cbuild.addStep(chromium_step.AnnotatedCommand, |
350 command=cmd, | 346 command=cmd, |
351 timeout=self.timeout, | 347 timeout=self.timeout, |
352 name=script, | 348 name=script, |
353 description=script, | 349 description=script, |
354 usePTY=False, | 350 usePTY=False, |
355 env={'PYTHONPATH':'.'}, | 351 env={'PYTHONPATH':'.'}, |
356 ** self.step_args) | 352 ** self.step_args) |
OLD | NEW |