| OLD | NEW |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Entry point for fully-annotated builds. | 5 """Entry point for fully-annotated builds. |
| 6 | 6 |
| 7 This script is part of the effort to move all builds to annotator-based | 7 This script is part of the effort to move all builds to annotator-based |
| 8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() | 8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() |
| 9 found in scripts/master/factory/annotator_factory.py executes a single | 9 found in scripts/master/factory/annotator_factory.py executes a single |
| 10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls | 10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 Args: | 194 Args: |
| 195 properties: a dictionary of properties to pass to the recipe. The | 195 properties: a dictionary of properties to pass to the recipe. The |
| 196 'recipe' property defines which recipe to actually run. | 196 'recipe' property defines which recipe to actually run. |
| 197 stream_engine: the StreamEngine to use to create individual step streams. | 197 stream_engine: the StreamEngine to use to create individual step streams. |
| 198 step_runner: The StepRunner to use to 'actually run' the steps. | 198 step_runner: The StepRunner to use to 'actually run' the steps. |
| 199 universe_view: The RecipeUniverse to use to load the recipes & modules. | 199 universe_view: The RecipeUniverse to use to load the recipes & modules. |
| 200 | 200 |
| 201 Returns: RecipeResult | 201 Returns: RecipeResult |
| 202 """ | 202 """ |
| 203 # NOTE(iannucci): 'root' was a terribly bad idea and has been replaced by | |
| 204 # 'patch_project'. 'root' had Rietveld knowing about the implementation of | |
| 205 # the builders. 'patch_project' lets the builder (recipe) decide its own | |
| 206 # destiny. | |
| 207 properties.pop('root', None) | |
| 208 | |
| 209 # TODO(iannucci): A much better way to do this would be to dynamically | |
| 210 # detect if the mirrors are actually available during the execution of the | |
| 211 # recipe. | |
| 212 if ('use_mirror' not in properties and ( | |
| 213 'TESTING_MASTERNAME' in os.environ or | |
| 214 'TESTING_SLAVENAME' in os.environ)): | |
| 215 properties['use_mirror'] = False | |
| 216 | |
| 217 with stream_engine.make_step_stream('setup_build') as s: | 203 with stream_engine.make_step_stream('setup_build') as s: |
| 218 engine = RecipeEngine(step_runner, properties, universe_view) | 204 engine = RecipeEngine(step_runner, properties, universe_view) |
| 219 | 205 |
| 220 # Create all API modules and top level RunSteps function. It doesn't launch | 206 # Create all API modules and top level RunSteps function. It doesn't launch |
| 221 # any recipe code yet; RunSteps needs to be called. | 207 # any recipe code yet; RunSteps needs to be called. |
| 222 api = None | 208 api = None |
| 223 | 209 |
| 224 assert 'recipe' in properties | 210 assert 'recipe' in properties |
| 225 recipe = properties['recipe'] | 211 recipe = properties['recipe'] |
| 226 | 212 |
| 227 properties_to_print = properties.copy() | |
| 228 if 'use_mirror' in properties: | |
| 229 del properties_to_print['use_mirror'] | |
| 230 | |
| 231 root_package = universe_view.universe.package_deps.root_package | 213 root_package = universe_view.universe.package_deps.root_package |
| 232 run_recipe_help_lines = [ | 214 run_recipe_help_lines = [ |
| 233 'To repro this locally, run the following line from the root of a %r' | 215 'To repro this locally, run the following line from the root of a %r' |
| 234 ' checkout:' % (root_package.name), | 216 ' checkout:' % (root_package.name), |
| 235 '', | 217 '', |
| 236 '%s run --properties-file - %s <<EOF' % ( | 218 '%s run --properties-file - %s <<EOF' % ( |
| 237 os.path.join( '.', root_package.relative_recipes_dir, 'recipes.py'), | 219 os.path.join( '.', root_package.relative_recipes_dir, 'recipes.py'), |
| 238 recipe), | 220 recipe), |
| 239 '%s' % json.dumps(properties_to_print), | 221 '%s' % json.dumps(properties), |
| 240 'EOF', | 222 'EOF', |
| 241 '', | 223 '', |
| 242 'To run on Windows, you can put the JSON in a file and redirect the', | 224 'To run on Windows, you can put the JSON in a file and redirect the', |
| 243 'contents of the file into run_recipe.py, with the < operator.', | 225 'contents of the file into run_recipe.py, with the < operator.', |
| 244 ] | 226 ] |
| 245 | 227 |
| 246 with s.new_log_stream('run_recipe') as l: | 228 with s.new_log_stream('run_recipe') as l: |
| 247 for line in run_recipe_help_lines: | 229 for line in run_recipe_help_lines: |
| 248 l.write_line(line) | 230 l.write_line(line) |
| 249 | 231 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 results.append( | 472 results.append( |
| 491 loader._invoke_with_properties( | 473 loader._invoke_with_properties( |
| 492 run_recipe, properties, recipe_script.PROPERTIES, | 474 run_recipe, properties, recipe_script.PROPERTIES, |
| 493 properties.keys())) | 475 properties.keys())) |
| 494 except TypeError as e: | 476 except TypeError as e: |
| 495 raise TypeError( | 477 raise TypeError( |
| 496 "Got %r while trying to call recipe %s with properties %r" % ( | 478 "Got %r while trying to call recipe %s with properties %r" % ( |
| 497 e, recipe, properties)) | 479 e, recipe, properties)) |
| 498 | 480 |
| 499 return results | 481 return results |
| OLD | NEW |