Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1079)

Side by Side Diff: recipe_engine/run.py

Issue 1421843006: Add simple depends_on API. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2013-2015 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013-2015 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 """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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 properties.pop('root', None) 426 properties.pop('root', None)
427 427
428 # TODO(iannucci): A much better way to do this would be to dynamically 428 # TODO(iannucci): A much better way to do this would be to dynamically
429 # detect if the mirrors are actually available during the execution of the 429 # detect if the mirrors are actually available during the execution of the
430 # recipe. 430 # recipe.
431 if ('use_mirror' not in properties and ( 431 if ('use_mirror' not in properties and (
432 'TESTING_MASTERNAME' in os.environ or 432 'TESTING_MASTERNAME' in os.environ or
433 'TESTING_SLAVENAME' in os.environ)): 433 'TESTING_SLAVENAME' in os.environ)):
434 properties['use_mirror'] = False 434 properties['use_mirror'] = False
435 435
436 engine = RecipeEngine(stream, properties, test_data) 436 engine = RecipeEngine(stream, properties, test_data, universe)
437 437
438 # Create all API modules and top level RunSteps function. It doesn't launch 438 # Create all API modules and top level RunSteps function. It doesn't launch
439 # any recipe code yet; RunSteps needs to be called. 439 # any recipe code yet; RunSteps needs to be called.
440 api = None 440 api = None
441 with stream.step('setup_build') as s: 441 with stream.step('setup_build') as s:
442 assert 'recipe' in properties 442 assert 'recipe' in properties
443 recipe = properties['recipe'] 443 recipe = properties['recipe']
444 444
445 properties_to_print = properties.copy() 445 properties_to_print = properties.copy()
446 if 'use_mirror' in properties: 446 if 'use_mirror' in properties:
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 Knows how to execute steps emitted by a recipe, holds global state such as 743 Knows how to execute steps emitted by a recipe, holds global state such as
744 step history and build properties. Each recipe module API has a reference to 744 step history and build properties. Each recipe module API has a reference to
745 this object. 745 this object.
746 746
747 Recipe modules that are aware of the engine: 747 Recipe modules that are aware of the engine:
748 * properties - uses engine.properties. 748 * properties - uses engine.properties.
749 * step_history - uses engine.step_history. 749 * step_history - uses engine.step_history.
750 * step - uses engine.create_step(...). 750 * step - uses engine.create_step(...).
751 751
752 """ 752 """
753 def __init__(self, stream, properties, test_data): 753 def __init__(self, stream, properties, test_data, universe):
754 self._stream = stream 754 self._stream = stream
755 self._properties = properties 755 self._properties = properties
756 self._test_data = test_data 756 self._test_data = test_data
757 self._step_history = collections.OrderedDict() 757 self._step_history = collections.OrderedDict()
758 self._universe = universe
758 759
759 self._previous_step_annotation = None 760 self._previous_step_annotation = None
760 self._previous_step_result = None 761 self._previous_step_result = None
761 self._api = None 762 self._api = None
762 763
763 @property 764 @property
764 def properties(self): 765 def properties(self):
765 return self._properties 766 return self._properties
766 767
767 @property 768 @property
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 exc = recipe_api.InfraFailure 855 exc = recipe_api.InfraFailure
855 856
856 step_result.presentation.status = state 857 step_result.presentation.status = state
857 if step_test.enabled: 858 if step_test.enabled:
858 # To avoid cluttering the expectations, don't emit this in testmode. 859 # To avoid cluttering the expectations, don't emit this in testmode.
859 self._previous_step_annotation.emit( 860 self._previous_step_annotation.emit(
860 'step returned non-zero exit code: %d' % step_result.retcode) 861 'step returned non-zero exit code: %d' % step_result.retcode)
861 862
862 raise exc(step['name'], step_result) 863 raise exc(step['name'], step_result)
863 864
864
865 def run(self, recipe_script, api): 865 def run(self, recipe_script, api):
866 """Run a recipe represented by a recipe_script object. 866 """Run a recipe represented by a recipe_script object.
867 867
868 This function blocks until recipe finishes. 868 This function blocks until recipe finishes.
869 869
870 Args: 870 Args:
871 recipe_script: The recipe to run, as represented by a RecipeScript object. 871 recipe_script: The recipe to run, as represented by a RecipeScript object.
872 api: The api, with loaded module dependencies. 872 api: The api, with loaded module dependencies.
873 Used by the some special modules. 873 Used by the some special modules.
874 874
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 Args: 934 Args:
935 step: ConfigGroup object with information about the step, see 935 step: ConfigGroup object with information about the step, see
936 recipe_modules/step/config.py. 936 recipe_modules/step/config.py.
937 937
938 Returns: 938 Returns:
939 Opaque engine specific object that is understood by 'run_steps' method. 939 Opaque engine specific object that is understood by 'run_steps' method.
940 """ 940 """
941 return step.as_jsonish() 941 return step.as_jsonish()
942 942
943 943
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698