| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Entry point for fully-annotated builds. | 6 """Entry point for fully-annotated builds. |
| 7 | 7 |
| 8 This script is part of the effort to move all builds to annotator-based | 8 This script is part of the effort to move all builds to annotator-based |
| 9 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() | 9 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() |
| 10 found in scripts/master/factory/annotator_factory.py executes a single | 10 found in scripts/master/factory/annotator_factory.py executes a single |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 help='factory properties in b64 gz JSON format') | 307 help='factory properties in b64 gz JSON format') |
| 308 parser.add_option('--keep-stdin', action='store_true', default=False, | 308 parser.add_option('--keep-stdin', action='store_true', default=False, |
| 309 help='don\'t close stdin when running recipe steps') | 309 help='don\'t close stdin when running recipe steps') |
| 310 return parser.parse_args(argv) | 310 return parser.parse_args(argv) |
| 311 | 311 |
| 312 | 312 |
| 313 def main(argv=None): | 313 def main(argv=None): |
| 314 opts, _ = get_args(argv) | 314 opts, _ = get_args(argv) |
| 315 | 315 |
| 316 stream = annotator.StructuredAnnotationStream() | 316 stream = annotator.StructuredAnnotationStream() |
| 317 universe = recipe_loader.RecipeUniverse() |
| 317 | 318 |
| 318 ret = run_steps(stream, opts.build_properties, opts.factory_properties) | 319 ret = run_steps(stream, opts.build_properties, opts.factory_properties, |
| 320 universe) |
| 319 return ret.status_code | 321 return ret.status_code |
| 320 | 322 |
| 321 | 323 |
| 322 # Return value of run_steps and RecipeEngine.run. | 324 # Return value of run_steps and RecipeEngine.run. |
| 323 RecipeExecutionResult = collections.namedtuple( | 325 RecipeExecutionResult = collections.namedtuple( |
| 324 'RecipeExecutionResult', 'status_code steps_ran') | 326 'RecipeExecutionResult', 'status_code steps_ran') |
| 325 | 327 |
| 326 | 328 |
| 327 def get_recipe_properties(factory_properties, build_properties): | 329 def get_recipe_properties(factory_properties, build_properties): |
| 328 """Constructs the recipe's properties from buildbot's properties. | 330 """Constructs the recipe's properties from buildbot's properties. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 351 properties['recipe'] = builder['recipe'] | 353 properties['recipe'] = builder['recipe'] |
| 352 properties.update(builder.get('properties', {})) | 354 properties.update(builder.get('properties', {})) |
| 353 else: | 355 else: |
| 354 raise LookupError('Cannot find recipe for %s on %s' % | 356 raise LookupError('Cannot find recipe for %s on %s' % |
| 355 (build_properties['buildername'], | 357 (build_properties['buildername'], |
| 356 build_properties['mastername'])) | 358 build_properties['mastername'])) |
| 357 return properties | 359 return properties |
| 358 | 360 |
| 359 | 361 |
| 360 def run_steps(stream, build_properties, factory_properties, | 362 def run_steps(stream, build_properties, factory_properties, |
| 361 test_data=recipe_test_api.DisabledTestData()): | 363 universe, test_data=recipe_test_api.DisabledTestData()): |
| 362 """Returns a tuple of (status_code, steps_ran). | 364 """Returns a tuple of (status_code, steps_ran). |
| 363 | 365 |
| 364 Only one of these values will be set at a time. This is mainly to support the | 366 Only one of these values will be set at a time. This is mainly to support the |
| 365 testing interface used by unittests/recipes_test.py. | 367 testing interface used by unittests/recipes_test.py. |
| 366 """ | 368 """ |
| 367 stream.honor_zero_return_code() | 369 stream.honor_zero_return_code() |
| 368 | 370 |
| 369 # TODO(iannucci): Stop this when blamelist becomes sane data. | 371 # TODO(iannucci): Stop this when blamelist becomes sane data. |
| 370 if ('blamelist_real' in build_properties and | 372 if ('blamelist_real' in build_properties and |
| 371 'blamelist' in build_properties): | 373 'blamelist' in build_properties): |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 '', | 418 '', |
| 417 'To run on Windows, you can put the JSON in a file and redirect the', | 419 'To run on Windows, you can put the JSON in a file and redirect the', |
| 418 'contents of the file into run_recipe.py, with the < operator.', | 420 'contents of the file into run_recipe.py, with the < operator.', |
| 419 ] | 421 ] |
| 420 | 422 |
| 421 for line in run_recipe_help_lines: | 423 for line in run_recipe_help_lines: |
| 422 s.step_log_line('run_recipe', line) | 424 s.step_log_line('run_recipe', line) |
| 423 s.step_log_end('run_recipe') | 425 s.step_log_end('run_recipe') |
| 424 | 426 |
| 425 try: | 427 try: |
| 426 recipe_module = recipe_loader.load_recipe(recipe) | 428 recipe_module = universe.load_recipe(recipe) |
| 427 stream.emit('Running recipe with %s' % (properties,)) | 429 stream.emit('Running recipe with %s' % (properties,)) |
| 428 api = recipe_loader.create_recipe_api(recipe_module.DEPS, | 430 api = recipe_loader.create_recipe_api(recipe_module.LOADED_DEPS, |
| 429 engine, | 431 engine, |
| 430 test_data) | 432 test_data) |
| 431 steps = recipe_module.GenSteps | 433 steps = recipe_module.GenSteps |
| 432 s.step_text('<br/>running recipe: "%s"' % recipe) | 434 s.step_text('<br/>running recipe: "%s"' % recipe) |
| 433 except recipe_loader.NoSuchRecipe as e: | 435 except recipe_loader.NoSuchRecipe as e: |
| 434 s.step_text('<br/>recipe not found: %s' % e) | 436 s.step_text('<br/>recipe not found: %s' % e) |
| 435 s.step_failure() | 437 s.step_failure() |
| 436 return RecipeExecutionResult(2, None) | 438 return RecipeExecutionResult(2, None) |
| 437 | 439 |
| 438 # Run the steps emitted by a recipe via the engine, emitting annotations | 440 # Run the steps emitted by a recipe via the engine, emitting annotations |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 | 707 |
| 706 def shell_main(argv): | 708 def shell_main(argv): |
| 707 if update_scripts(): | 709 if update_scripts(): |
| 708 return subprocess.call([sys.executable] + argv) | 710 return subprocess.call([sys.executable] + argv) |
| 709 else: | 711 else: |
| 710 return main(argv) | 712 return main(argv) |
| 711 | 713 |
| 712 | 714 |
| 713 if __name__ == '__main__': | 715 if __name__ == '__main__': |
| 714 sys.exit(shell_main(sys.argv)) | 716 sys.exit(shell_main(sys.argv)) |
| OLD | NEW |