OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 cgi | 5 import cgi |
6 import re | 6 import re |
7 | 7 |
8 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
9 | 9 |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 break | 76 break |
77 else: | 77 else: |
78 raise self.m.step.StepFailure('Could not find tryjob description.') | 78 raise self.m.step.StepFailure('Could not find tryjob description.') |
79 | 79 |
80 # Load the tryjob description file. | 80 # Load the tryjob description file. |
81 desc_json = self.m.gitiles.download_file( | 81 desc_json = self.m.gitiles.download_file( |
82 repository, desc_path, branch=revision, | 82 repository, desc_path, branch=revision, |
83 step_name=str('Fetch tryjob descriptor (%s)' % (desc_path,)), | 83 step_name=str('Fetch tryjob descriptor (%s)' % (desc_path,)), |
84 attempts=self._GITILES_ATTEMPTS) | 84 attempts=self._GITILES_ATTEMPTS) |
85 result = self.m.step.active_result | 85 result = self.m.step.active_result |
| 86 result.presentation.logs['tryjob.json'] = [desc_json] |
86 | 87 |
87 # Parse the commit description from the file (JSON). | 88 # Parse the commit description from the file (JSON). |
88 desc = self.m.json.loads(desc_json) | 89 desc = self.m.json.loads(desc_json) |
89 result.presentation.step_text += '<br/>'.join( | |
90 '%s: %s' % (k, cgi.escape(str(v))) | |
91 for k, v in desc.iteritems()) | |
92 return desc.get('extra_args', ()) | 90 return desc.get('extra_args', ()) |
93 | 91 |
94 def load_manifest_config(self, repository, revision): | 92 def load_manifest_config(self, repository, revision): |
95 """Loads manifest-specified parameters from the manifest commit. | 93 """Loads manifest-specified parameters from the manifest commit. |
96 | 94 |
97 This method parses the commit log for the following information: | 95 This method parses the commit log for the following information: |
98 - The branch to build (From the "Automatic": tag). | 96 - The branch to build (From the "Automatic": tag). |
99 - The build ID (from the CrOS-Build-Id: tag). | 97 - The build ID (from the CrOS-Build-Id: tag). |
100 | 98 |
101 Args: | 99 Args: |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 # Apply any variant configurations. | 231 # Apply any variant configurations. |
234 if variant: | 232 if variant: |
235 for config_name in config_map.get('variants', {}).get(variant, ()): | 233 for config_name in config_map.get('variants', {}).get(variant, ()): |
236 self.apply_config(config_name) | 234 self.apply_config(config_name) |
237 | 235 |
238 | 236 |
239 # If a config repo was specified, use it. | 237 # If a config repo was specified, use it. |
240 if 'config_repo' in properties: | 238 if 'config_repo' in properties: |
241 self.c.cbb.config_repo = self.m.properties['config_repo'] | 239 self.c.cbb.config_repo = self.m.properties['config_repo'] |
242 | 240 |
243 def run_cbuildbot(self, tryjob=False): | 241 def run_cbuildbot(self, args=[]): |
244 """Runs a 'cbuildbot' checkout-and-build workflow. | 242 """Runs a 'cbuildbot' checkout-and-build workflow. |
245 | 243 |
246 This workflow uses the registered configuration dictionary to make master- | 244 This workflow uses the registered configuration dictionary to make master- |
247 and builder-specific changes to the standard workflow. | 245 and builder-specific changes to the standard workflow. |
248 | 246 |
249 The specific workflow paths that are taken are also influenced by several | 247 The specific workflow paths that are taken are also influenced by several |
250 build properties. | 248 build properties. |
251 | 249 |
252 TODO(dnj): When CrOS migrates away from BuildBot, replace property | 250 TODO(dnj): When CrOS migrates away from BuildBot, replace property |
253 inferences with command-line parameters. | 251 inferences with command-line parameters. |
254 | 252 |
255 This workflow: | 253 This workflow: |
256 - Checks out the specified 'cbuildbot' repository. | 254 - Checks out the specified 'cbuildbot' repository. |
257 - Pulls information based on the configured change's repository/revision | 255 - Pulls information based on the configured change's repository/revision |
258 to pass to 'cbuildbot'. | 256 to pass to 'cbuildbot'. |
259 - Executes the 'cbuildbot' command. | 257 - Executes the 'cbuildbot' command. |
260 | 258 |
261 Args: | 259 Args: |
262 tryjob (bool): If True, load a tryjob description from the source | 260 args (list): If True, use this argument list as the base instead of the |
263 repository and augment the cbuildbot command-line with it. | 261 default, which is '--buildbot'. |
264 Returns: (Step) the 'cbuildbot' execution step. | 262 Returns: (Step) the 'cbuildbot' execution step. |
265 """ | 263 """ |
266 # Assert correct configuration. | 264 # Assert correct configuration. |
267 assert self.c.cbb.config, 'An empty configuration was specified.' | 265 assert self.c.cbb.config, 'An empty configuration was specified.' |
268 assert self.c.cbb.builddir, 'A build directory name must be specified.' | 266 assert self.c.cbb.builddir, 'A build directory name must be specified.' |
269 | 267 |
270 # Load properties from the commit being processed. This requires both a | 268 # Load properties from the commit being processed. This requires both a |
271 # repository and revision to proceed. | 269 # repository and revision to proceed. |
272 repository = self.m.properties.get('repository') | 270 repository = self.m.properties.get('repository') |
273 revision = self.m.properties.get('revision') | 271 revision = self.m.properties.get('revision') |
274 tryjob_args = [] | |
275 if repository and revision: | 272 if repository and revision: |
276 if tryjob: | |
277 assert self.check_repository('tryjob', repository), ( | |
278 "Refusing to query unknown tryjob repository: %s" % (repository,)) | |
279 # If we are a tryjob, add parameters specified in the description. | |
280 tryjob_args = self.load_try_job(repository, revision) | |
281 | |
282 # Pull more information from the commit if it came from certain known | 273 # Pull more information from the commit if it came from certain known |
283 # repositories. | 274 # repositories. |
284 if (self.c.use_chrome_version and | 275 if (self.c.use_chrome_version and |
285 self.check_repository('chromium', repository)): | 276 self.check_repository('chromium', repository)): |
286 # If our change comes from a Chromium repository, add the | 277 # If our change comes from a Chromium repository, add the |
287 # '--chrome_version' flag. | 278 # '--chrome_version' flag. |
288 self.c.cbb.chrome_version = self.m.properties['revision'] | 279 self.c.cbb.chrome_version = self.m.properties['revision'] |
289 if (self.c.read_cros_manifest and | 280 if (self.c.read_cros_manifest and |
290 self.check_repository('cros_manifest', repository)): | 281 self.check_repository('cros_manifest', repository)): |
291 # This change comes from a manifest repository. Load configuration | 282 # This change comes from a manifest repository. Load configuration |
292 # parameters from the manifest command. | 283 # parameters from the manifest command. |
293 self.load_manifest_config(repository, revision) | 284 self.load_manifest_config(repository, revision) |
294 | 285 |
295 buildroot = self.m.path['root'].join('cbuild', self.c.cbb.builddir) | 286 buildroot = self.m.path['root'].join('cbuild', self.c.cbb.builddir) |
296 cbb_args = [ | 287 cbb_args = [ |
297 '--buildroot', buildroot, | 288 '--buildroot', buildroot, |
298 ] | 289 ] |
299 if not tryjob: | 290 if not args: |
300 cbb_args.append('--buildbot') | 291 cbb_args.append('--buildbot') |
301 if self.c.chromite_branch and not self.c.cbb.disable_bootstrap: | 292 if self.c.chromite_branch and not self.c.cbb.disable_bootstrap: |
302 cbb_args.extend(['--branch', self.c.chromite_branch]) | 293 cbb_args.extend(['--branch', self.c.chromite_branch]) |
303 if self.c.cbb.build_number is not None: | 294 if self.c.cbb.build_number is not None: |
304 cbb_args.extend(['--buildnumber', self.c.cbb.build_number]) | 295 cbb_args.extend(['--buildnumber', self.c.cbb.build_number]) |
305 if self.c.cbb.chrome_rev: | 296 if self.c.cbb.chrome_rev: |
306 cbb_args.extend(['--chrome_rev', self.c.cbb.chrome_rev]) | 297 cbb_args.extend(['--chrome_rev', self.c.cbb.chrome_rev]) |
307 if self.c.cbb.debug: | 298 if self.c.cbb.debug: |
308 cbb_args.extend(['--debug']) | 299 cbb_args.extend(['--debug']) |
309 if self.c.cbb.clobber: | 300 if self.c.cbb.clobber: |
310 cbb_args.extend(['--clobber']) | 301 cbb_args.extend(['--clobber']) |
311 if self.c.cbb.chrome_version: | 302 if self.c.cbb.chrome_version: |
312 cbb_args.extend(['--chrome_version', self.c.cbb.chrome_version]) | 303 cbb_args.extend(['--chrome_version', self.c.cbb.chrome_version]) |
313 if self.c.cbb.config_repo: | 304 if self.c.cbb.config_repo: |
314 cbb_args.extend(['--config_repo', self.c.cbb.config_repo]) | 305 cbb_args.extend(['--config_repo', self.c.cbb.config_repo]) |
315 | 306 |
316 # Set the build ID, if specified. | 307 # Set the build ID, if specified. |
317 if self.c.cbb.build_id: | 308 if self.c.cbb.build_id: |
318 cbb_args.extend(['--master-build-id', self.c.cbb.build_id]) | 309 cbb_args.extend(['--master-build-id', self.c.cbb.build_id]) |
319 | 310 |
320 # Add tryjob args, if there are any. | 311 # Add custom args, if there are any. |
321 cbb_args.extend(tryjob_args) | 312 cbb_args.extend(args) |
322 | 313 |
323 # Checkout Chromite. | 314 # Checkout Chromite. |
324 self.m.bot_update.ensure_checkout( | 315 self.m.bot_update.ensure_checkout( |
325 gclient_config=self.gclient_config(), | 316 gclient_config=self.gclient_config(), |
326 update_presentation=False, | 317 update_presentation=False, |
327 force=True) | 318 force=True) |
328 if self.c.chromite_branch and self.c.cbb.disable_bootstrap: | 319 if self.c.chromite_branch and self.c.cbb.disable_bootstrap: |
329 # Chromite auto-detects which branch to build for based on its current | 320 # Chromite auto-detects which branch to build for based on its current |
330 # checkout. "bot_update" checks out remote branches, but Chromite requires | 321 # checkout. "bot_update" checks out remote branches, but Chromite requires |
331 # a local branch. | 322 # a local branch. |
332 # | 323 # |
333 # Normally we'd bootstrap, but if we're disabling bootstrapping, we have | 324 # Normally we'd bootstrap, but if we're disabling bootstrapping, we have |
334 # to checkout the local branch to let Chromite know which branch to build. | 325 # to checkout the local branch to let Chromite know which branch to build. |
335 self.m.git('checkout', self.c.chromite_branch, | 326 self.m.git('checkout', self.c.chromite_branch, |
336 name=str('checkout chromite branch [%s]' % (self.c.chromite_branch))) | 327 name=str('checkout chromite branch [%s]' % (self.c.chromite_branch))) |
337 | 328 |
338 # Run cbuildbot. | 329 # Run cbuildbot. |
339 return self.cbuildbot(str('cbuildbot [%s]' % (self.c.cbb.config,)), | 330 return self.cbuildbot(str('cbuildbot [%s]' % (self.c.cbb.config,)), |
340 self.c.cbb.config, | 331 self.c.cbb.config, |
341 args=cbb_args, | 332 args=cbb_args, |
342 chromite_path=self.m.path['checkout'], | 333 chromite_path=self.m.path['checkout'], |
343 cwd=self.m.path['slave_root']) | 334 cwd=self.m.path['slave_root']) |
OLD | NEW |