Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2017 The LUCI Authors. All rights reserved. | 1 # Copyright 2017 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 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api |
| 6 | 6 |
| 7 class GeneratorScriptApi(recipe_api.RecipeApi): | 7 class GeneratorScriptApi(recipe_api.RecipeApi): |
| 8 def __call__(self, path_to_script, *args, **kwargs): | 8 def __call__(self, path_to_script, *args, **kwargs): |
| 9 """Run a script and generate the steps emitted by that script. | 9 """Run a script and generate the steps emitted by that script. |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 step['env'] = new_env | 84 step['env'] = new_env |
| 85 outputs_json = step.pop('outputs_presentation_json', False) | 85 outputs_json = step.pop('outputs_presentation_json', False) |
| 86 if outputs_json: | 86 if outputs_json: |
| 87 # This step has requested a JSON file which the binary that | 87 # This step has requested a JSON file which the binary that |
| 88 # it invokes can write to, so provide it with one. | 88 # it invokes can write to, so provide it with one. |
| 89 step['cmd'].extend(['--presentation-json', self.m.json.output(False)]) | 89 step['cmd'].extend(['--presentation-json', self.m.json.output(False)]) |
| 90 | 90 |
| 91 #TODO(martiniss) change this to use a regular step call | 91 #TODO(martiniss) change this to use a regular step call |
| 92 step['ok_ret'] = set(step.pop('ok_ret', {0})) | 92 step['ok_ret'] = set(step.pop('ok_ret', {0})) |
| 93 step['infra_step'] = bool(step.pop('infra_step', False)) | 93 step['infra_step'] = bool(step.pop('infra_step', False)) |
| 94 step['step_nest_level'] = step.pop('step_nest_level', 0) | 94 step['nest_level'] = step.pop('step_nest_level', 0) |
| 95 | 95 |
| 96 if step.pop('always_run', False) or not failed_steps: | 96 if step.pop('always_run', False) or not failed_steps: |
| 97 try: | 97 try: |
| 98 self.m.step.run_from_dict(step) | 98 self.m.step.run_step(**step) |
|
iannucci
2017/06/12 18:20:08
this needs rebasing
| |
| 99 except self.m.step.StepFailure: | 99 except self.m.step.StepFailure: |
| 100 failed_steps.append(step['name']) | 100 failed_steps.append(step['name']) |
| 101 finally: | 101 finally: |
| 102 step_result = self.m.step.active_result | 102 step_result = self.m.step.active_result |
| 103 if outputs_json: | 103 if outputs_json: |
| 104 p = step_result.presentation | 104 p = step_result.presentation |
| 105 j = step_result.json.output | 105 j = step_result.json.output |
| 106 | 106 |
| 107 if j: | 107 if j: |
| 108 p.logs.update(j.get('logs', {})) | 108 p.logs.update(j.get('logs', {})) |
| 109 p.links.update(j.get('links', {})) | 109 p.links.update(j.get('links', {})) |
| 110 p.step_summary_text = j.get('step_summary_text', '') | 110 p.step_summary_text = j.get('step_summary_text', '') |
| 111 p.step_text = j.get('step_text', '') | 111 p.step_text = j.get('step_text', '') |
| 112 p.properties.update(j.get('properties', {})) | 112 p.properties.update(j.get('properties', {})) |
| 113 | 113 |
| 114 if failed_steps: | 114 if failed_steps: |
| 115 raise self.m.step.StepFailure( | 115 raise self.m.step.StepFailure( |
| 116 "the following steps in %s failed: %s" % | 116 "the following steps in %s failed: %s" % |
| 117 (step_name, failed_steps)) | 117 (step_name, failed_steps)) |
| OLD | NEW |