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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 """ | 289 """ |
290 Knows how to execute steps emitted by a recipe, holds global state such as | 290 Knows how to execute steps emitted by a recipe, holds global state such as |
291 step history and build properties. Each recipe module API has a reference to | 291 step history and build properties. Each recipe module API has a reference to |
292 this object. | 292 this object. |
293 | 293 |
294 Recipe modules that are aware of the engine: | 294 Recipe modules that are aware of the engine: |
295 * properties - uses engine.properties. | 295 * properties - uses engine.properties. |
296 * step - uses engine.create_step(...), and previous_step_result. | 296 * step - uses engine.create_step(...), and previous_step_result. |
297 """ | 297 """ |
298 | 298 |
299 ActiveStep = collections.namedtuple('ActiveStep', | 299 ActiveStep = collections.namedtuple('ActiveStep', ( |
300 'step step_result open_step nest_level') | 300 'step', 'step_result', 'open_step', 'nest_level')) |
301 | 301 |
302 def __init__(self, step_runner, properties, universe_view): | 302 def __init__(self, step_runner, properties, universe_view): |
303 """See run_steps() for parameter meanings.""" | 303 """See run_steps() for parameter meanings.""" |
304 self._step_runner = step_runner | 304 self._step_runner = step_runner |
305 self._properties = properties | 305 self._properties = properties |
306 self._universe_view = universe_view | 306 self._universe_view = universe_view |
307 | 307 |
308 # A stack of ActiveStep objects, holding the most recently executed step at | 308 # A stack of ActiveStep objects, holding the most recently executed step at |
309 # each nest level (objects deeper in the stack have lower nest levels). | 309 # each nest level (objects deeper in the stack have lower nest levels). |
310 # When we pop from this stack, we close the corresponding step stream. | 310 # When we pop from this stack, we close the corresponding step stream. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 Returns: | 361 Returns: |
362 A StepData object containing the result of running the step. | 362 A StepData object containing the result of running the step. |
363 """ | 363 """ |
364 with util.raises((recipe_api.StepFailure, OSError), | 364 with util.raises((recipe_api.StepFailure, OSError), |
365 self._step_runner.stream_engine): | 365 self._step_runner.stream_engine): |
366 ok_ret = step.pop('ok_ret') | 366 ok_ret = step.pop('ok_ret') |
367 infra_step = step.pop('infra_step') | 367 infra_step = step.pop('infra_step') |
368 | 368 |
369 step_result = None | 369 step_result = None |
370 | 370 |
371 nest_level = step.pop('step_nest_level', 0) | 371 nest_level = step.get('step_nest_level', 0) |
372 self._close_to_level(nest_level) | 372 self._close_to_level(nest_level) |
373 | 373 |
374 open_step = self._step_runner.open_step(step) | 374 open_step = self._step_runner.open_step(step) |
375 self._step_stack.append(self.ActiveStep( | 375 self._step_stack.append(self.ActiveStep( |
376 step=step, | 376 step=step, |
377 step_result=None, | 377 step_result=None, |
378 open_step=open_step, | 378 open_step=open_step, |
379 nest_level=nest_level)) | 379 nest_level=nest_level)) |
380 if nest_level: | |
381 open_step.stream.set_nest_level(nest_level) | |
382 | 380 |
383 step_result = open_step.run() | 381 step_result = open_step.run() |
384 self._step_stack[-1] = ( | 382 self._step_stack[-1] = ( |
385 self._step_stack[-1]._replace(step_result=step_result)) | 383 self._step_stack[-1]._replace(step_result=step_result)) |
386 | 384 |
387 if step_result.retcode in ok_ret: | 385 if step_result.retcode in ok_ret: |
388 step_result.presentation.status = 'SUCCESS' | 386 step_result.presentation.status = 'SUCCESS' |
389 return step_result | 387 return step_result |
390 else: | 388 else: |
391 if not infra_step: | 389 if not infra_step: |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 results.append( | 499 results.append( |
502 loader._invoke_with_properties( | 500 loader._invoke_with_properties( |
503 run_recipe, properties, recipe_script.PROPERTIES, | 501 run_recipe, properties, recipe_script.PROPERTIES, |
504 properties.keys())) | 502 properties.keys())) |
505 except TypeError as e: | 503 except TypeError as e: |
506 raise TypeError( | 504 raise TypeError( |
507 "Got %r while trying to call recipe %s with properties %r" % ( | 505 "Got %r while trying to call recipe %s with properties %r" % ( |
508 e, recipe, properties)) | 506 e, recipe, properties)) |
509 | 507 |
510 return results | 508 return results |
OLD | NEW |