Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 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 12 matching lines...) Expand all Loading... | |
| 23 env: a {key:value} dictionary of the environment variables to override. | 23 env: a {key:value} dictionary of the environment variables to override. |
| 24 every value is formatted with the current environment with the python | 24 every value is formatted with the current environment with the python |
| 25 % operator, so a value of "%(PATH)s:/some/other/path" would resolve to | 25 % operator, so a value of "%(PATH)s:/some/other/path" would resolve to |
| 26 the current PATH value, concatenated with ":/some/other/path" | 26 the current PATH value, concatenated with ":/some/other/path" |
| 27 | 27 |
| 28 ok_ret: a list of non-error return codes. This defaults to [0] | 28 ok_ret: a list of non-error return codes. This defaults to [0] |
| 29 | 29 |
| 30 infra_step: a bool which indicates that failures in this step are 'infra' | 30 infra_step: a bool which indicates that failures in this step are 'infra' |
| 31 failures and should abort with a purple coloration instead red. | 31 failures and should abort with a purple coloration instead red. |
| 32 | 32 |
| 33 step_nest_level: an integer which indicates that this step should appear | 33 nested: true if this step is nested. |
| 34 on the build status page with this indentation level. | |
| 35 | 34 |
| 36 always_run: a bool which indicates that this step should run, even if | 35 always_run: a bool which indicates that this step should run, even if |
| 37 some previous step failed. | 36 some previous step failed. |
| 38 | 37 |
| 39 outputs_presentation_json: a bool which indicates that this step will emit | 38 outputs_presentation_json: a bool which indicates that this step will emit |
| 40 a presentation json file. If this is True, the cmd will be extended with | 39 a presentation json file. If this is True, the cmd will be extended with |
| 41 a `--presentation-json /path/to/file.json`. This file will be used to | 40 a `--presentation-json /path/to/file.json`. This file will be used to |
| 42 update the step's presentation on the build status page. The file will | 41 update the step's presentation on the build status page. The file will |
| 43 be expected to contain a single json object, with any of the following | 42 be expected to contain a single json object, with any of the following |
| 44 keys: | 43 keys: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 step['env'] = new_env | 82 step['env'] = new_env |
| 84 outputs_json = step.pop('outputs_presentation_json', False) | 83 outputs_json = step.pop('outputs_presentation_json', False) |
| 85 if outputs_json: | 84 if outputs_json: |
| 86 # This step has requested a JSON file which the binary that | 85 # This step has requested a JSON file which the binary that |
| 87 # it invokes can write to, so provide it with one. | 86 # it invokes can write to, so provide it with one. |
| 88 step['cmd'].extend(['--presentation-json', self.m.json.output(False)]) | 87 step['cmd'].extend(['--presentation-json', self.m.json.output(False)]) |
| 89 | 88 |
| 90 #TODO(martiniss) change this to use a regular step call | 89 #TODO(martiniss) change this to use a regular step call |
| 91 step['ok_ret'] = set(step.pop('ok_ret', {0})) | 90 step['ok_ret'] = set(step.pop('ok_ret', {0})) |
| 92 step['infra_step'] = bool(step.pop('infra_step', False)) | 91 step['infra_step'] = bool(step.pop('infra_step', False)) |
| 93 step['step_nest_level'] = int(step.pop('step_nest_level', 0)) | |
|
dnj
2016/08/15 17:33:53
(This will be re-added in next PS, was oversight).
| |
| 94 | 92 |
| 95 if step.pop('always_run', False) or not failed_steps: | 93 if step.pop('always_run', False) or not failed_steps: |
| 96 try: | 94 try: |
| 97 self.m.step.run_from_dict(step) | 95 self.m.step.run_from_dict(step) |
| 98 except self.m.step.StepFailure: | 96 except self.m.step.StepFailure: |
| 99 failed_steps.append(step['name']) | 97 failed_steps.append(step['name']) |
| 100 finally: | 98 finally: |
| 101 step_result = self.m.step.active_result | 99 step_result = self.m.step.active_result |
| 102 if outputs_json: | 100 if outputs_json: |
| 103 p = step_result.presentation | 101 p = step_result.presentation |
| 104 j = step_result.json.output | 102 j = step_result.json.output |
| 105 | 103 |
| 106 if j: | 104 if j: |
| 107 p.logs.update(j.get('logs', {})) | 105 p.logs.update(j.get('logs', {})) |
| 108 p.links.update(j.get('links', {})) | 106 p.links.update(j.get('links', {})) |
| 109 p.step_summary_text = j.get('step_summary_text', '') | 107 p.step_summary_text = j.get('step_summary_text', '') |
| 110 p.step_text = j.get('step_text', '') | 108 p.step_text = j.get('step_text', '') |
| 111 p.properties.update(j.get('properties', {})) | 109 p.properties.update(j.get('properties', {})) |
| 112 | 110 |
| 113 if failed_steps: | 111 if failed_steps: |
| 114 raise self.m.step.StepFailure( | 112 raise self.m.step.StepFailure( |
| 115 "the following steps in %s failed: %s" % | 113 "the following steps in %s failed: %s" % |
| 116 (step_name, failed_steps)) | 114 (step_name, failed_steps)) |
| OLD | NEW |