Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import copy | 7 import copy |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| 11 import subprocess | 11 import subprocess |
| 12 import sys | 12 import sys |
| 13 import tempfile | 13 import tempfile |
| 14 | 14 |
| 15 | 15 |
| 16 # Install Infra build environment. | 16 # Install Infra build environment. |
| 17 BUILD_ROOT = os.path.dirname(os.path.dirname(os.path.dirname( | 17 BUILD_ROOT = os.path.dirname(os.path.dirname(os.path.dirname( |
| 18 os.path.abspath(__file__)))) | 18 os.path.abspath(__file__)))) |
| 19 sys.path.insert(0, os.path.join(BUILD_ROOT, 'scripts')) | 19 sys.path.insert(0, os.path.join(BUILD_ROOT, 'scripts')) |
| 20 | 20 |
| 21 from common import annotator | |
| 21 from common import chromium_utils | 22 from common import chromium_utils |
| 22 from common import env | 23 from common import env |
| 23 from slave import cipd | 24 from slave import cipd |
| 24 from slave import infra_platform | 25 from slave import infra_platform |
| 25 from slave import logdog_bootstrap | 26 from slave import logdog_bootstrap |
| 26 from slave import monitoring_utils | 27 from slave import monitoring_utils |
| 27 from slave import robust_tempdir | 28 from slave import robust_tempdir |
| 28 from slave import update_scripts | 29 from slave import update_scripts |
| 29 | 30 |
| 30 | 31 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 properties = copy.copy(args.factory_properties) | 112 properties = copy.copy(args.factory_properties) |
| 112 properties.update(args.build_properties) | 113 properties.update(args.build_properties) |
| 113 properties['build_data_dir'] = build_data_dir | 114 properties['build_data_dir'] = build_data_dir |
| 114 LOGGER.info('Using properties: %r', properties) | 115 LOGGER.info('Using properties: %r', properties) |
| 115 properties_file = os.path.join(tempdir, 'remote_run_properties.json') | 116 properties_file = os.path.join(tempdir, 'remote_run_properties.json') |
| 116 with open(properties_file, 'w') as f: | 117 with open(properties_file, 'w') as f: |
| 117 json.dump(properties, f) | 118 json.dump(properties, f) |
| 118 | 119 |
| 119 monitoring_utils.write_build_monitoring_event(build_data_dir, properties) | 120 monitoring_utils.write_build_monitoring_event(build_data_dir, properties) |
| 120 | 121 |
| 122 recipe_result_path = os.path.join(tempdir, 'recipe_result.json') | |
| 121 recipe_cmd = [ | 123 recipe_cmd = [ |
| 122 sys.executable, | 124 sys.executable, |
| 123 os.path.join(cipd_path, 'recipes.py'), | 125 os.path.join(cipd_path, 'recipes.py'), |
| 124 '--verbose', | 126 '--verbose', |
| 125 'remote', | 127 'remote', |
| 126 '--repository', args.repository, | 128 '--repository', args.repository, |
| 127 '--revision', args.revision, | 129 '--revision', args.revision, |
| 128 '--workdir', os.path.join(tempdir, 'rw'), | 130 '--workdir', os.path.join(tempdir, 'rw'), |
| 129 '--', | 131 '--', |
| 130 '--verbose', | 132 '--verbose', |
| 131 'run', | 133 'run', |
| 132 '--properties-file', properties_file, | 134 '--properties-file', properties_file, |
| 133 '--workdir', os.path.join(tempdir, 'w'), | 135 '--workdir', os.path.join(tempdir, 'w'), |
| 136 '--output-result-json', recipe_result_path, | |
| 134 args.recipe, | 137 args.recipe, |
| 135 ] | 138 ] |
| 136 # If we bootstrap through logdog, the recipe command line gets written | 139 # If we bootstrap through logdog, the recipe command line gets written |
| 137 # to a temporary file and does not appear in the log. | 140 # to a temporary file and does not appear in the log. |
| 138 LOGGER.info('Recipe command line: %r', recipe_cmd) | 141 LOGGER.info('Recipe command line: %r', recipe_cmd) |
| 139 recipe_return_code = None | 142 recipe_return_code = None |
| 140 try: | 143 try: |
| 141 bs = logdog_bootstrap.bootstrap(rt, args, basedir, tempdir, properties, | 144 bs = logdog_bootstrap.bootstrap(rt, args, basedir, tempdir, properties, |
| 142 recipe_cmd) | 145 recipe_cmd) |
| 143 | 146 |
| 144 LOGGER.info('Bootstrapping through LogDog: %s', bs.cmd) | 147 LOGGER.info('Bootstrapping through LogDog: %s', bs.cmd) |
| 145 _ = _call(bs.cmd) | 148 _ = _call(bs.cmd) |
| 146 recipe_return_code = bs.get_result() | 149 recipe_return_code = bs.get_result() |
| 147 except logdog_bootstrap.NotBootstrapped as e: | 150 except logdog_bootstrap.NotBootstrapped as e: |
| 148 LOGGER.info('Not bootstrapped: %s', e.message) | 151 LOGGER.info('Not bootstrapped: %s', e.message) |
| 149 except logdog_bootstrap.BootstrapError as e: | 152 except logdog_bootstrap.BootstrapError as e: |
| 150 LOGGER.warning('Could not bootstrap LogDog: %s', e.message) | 153 LOGGER.warning('Could not bootstrap LogDog: %s', e.message) |
| 151 except Exception as e: | 154 except Exception as e: |
| 152 LOGGER.exception('Exception while bootstrapping LogDog.') | 155 LOGGER.exception('Exception while bootstrapping LogDog.') |
| 153 finally: | 156 finally: |
| 154 if recipe_return_code is None: | 157 if recipe_return_code is None: |
| 155 LOGGER.info('Not using LogDog. Invoking `recipes.py` directly.') | 158 LOGGER.info('Not using LogDog. Invoking `recipes.py` directly.') |
| 156 recipe_return_code = _call(recipe_cmd) | 159 recipe_return_code = _call(recipe_cmd) |
| 160 | |
| 161 # Try to open recipe result JSON. Any failure will result in an exception | |
| 162 # and an infra failure. | |
| 163 with open(recipe_result_path) as f: | |
| 164 json.load(f) | |
| 157 return recipe_return_code | 165 return recipe_return_code |
| 158 | 166 |
| 159 | 167 |
| 160 def shell_main(argv): | 168 def shell_main(argv): |
| 161 logging.basicConfig( | 169 logging.basicConfig( |
| 162 level=(logging.DEBUG if '--verbose' in argv else logging.INFO)) | 170 level=(logging.DEBUG if '--verbose' in argv else logging.INFO)) |
| 163 | 171 |
| 164 if update_scripts.update_scripts(): | 172 if update_scripts.update_scripts(): |
| 165 # Re-execute with the updated remote_run.py. | 173 # Re-execute with the updated remote_run.py. |
| 166 return _call([sys.executable] + argv) | 174 return _call([sys.executable] + argv) |
| 167 | 175 |
| 168 return main(argv) | 176 stream = annotator.StructuredAnnotationStream() |
| 177 with stream.step('remote_run_result'): | |
|
martiniss
2016/07/08 21:10:29
Why is this here? You're creating another step bef
Paweł Hajdan Jr.
2016/07/11 11:21:07
Yes, this way I can turn that step purple e.g. on
| |
| 178 return main(argv) | |
| 169 | 179 |
| 170 | 180 |
| 171 if __name__ == '__main__': | 181 if __name__ == '__main__': |
| 172 sys.exit(shell_main(sys.argv)) | 182 sys.exit(shell_main(sys.argv)) |
| OLD | NEW |