OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
7 | 7 |
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
9 | 9 |
10 from __future__ import print_function | 10 from __future__ import print_function |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 try: | 35 try: |
36 import readline # pylint: disable=F0401,W0611 | 36 import readline # pylint: disable=F0401,W0611 |
37 except ImportError: | 37 except ImportError: |
38 pass | 38 pass |
39 | 39 |
40 from third_party import colorama | 40 from third_party import colorama |
41 from third_party import httplib2 | 41 from third_party import httplib2 |
42 from third_party import upload | 42 from third_party import upload |
43 import auth | 43 import auth |
44 from luci_hacks import trigger_luci_job as luci_trigger | |
45 import clang_format | 44 import clang_format |
46 import commit_queue | 45 import commit_queue |
47 import dart_format | 46 import dart_format |
48 import setup_color | 47 import setup_color |
49 import fix_encoding | 48 import fix_encoding |
50 import gclient_utils | 49 import gclient_utils |
51 import gerrit_util | 50 import gerrit_util |
52 import git_cache | 51 import git_cache |
53 import git_common | 52 import git_common |
54 import git_footers | 53 import git_footers |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 if response.status < 500 or try_count >= 2: | 273 if response.status < 500 or try_count >= 2: |
275 raise httplib2.HttpLib2Error(content) | 274 raise httplib2.HttpLib2Error(content) |
276 | 275 |
277 # status >= 500 means transient failures. | 276 # status >= 500 means transient failures. |
278 logging.debug('Transient errors when %s. Will retry.', operation_name) | 277 logging.debug('Transient errors when %s. Will retry.', operation_name) |
279 time.sleep(0.5 + 1.5*try_count) | 278 time.sleep(0.5 + 1.5*try_count) |
280 try_count += 1 | 279 try_count += 1 |
281 assert False, 'unreachable' | 280 assert False, 'unreachable' |
282 | 281 |
283 | 282 |
284 def trigger_luci_job(changelist, masters, options): | |
285 """Send a job to run on LUCI.""" | |
286 issue_props = changelist.GetIssueProperties() | |
287 issue = changelist.GetIssue() | |
288 patchset = changelist.GetMostRecentPatchset() | |
289 for builders_and_tests in sorted(masters.itervalues()): | |
290 # TODO(hinoka et al): add support for other properties. | |
291 # Currently, this completely ignores testfilter and other properties. | |
292 for builder in sorted(builders_and_tests): | |
293 luci_trigger.trigger( | |
294 builder, 'HEAD', issue, patchset, issue_props['project']) | |
295 | |
296 | |
297 def trigger_try_jobs(auth_config, changelist, options, masters, category): | 283 def trigger_try_jobs(auth_config, changelist, options, masters, category): |
298 rietveld_url = settings.GetDefaultServerUrl() | 284 rietveld_url = settings.GetDefaultServerUrl() |
299 rietveld_host = urlparse.urlparse(rietveld_url).hostname | 285 rietveld_host = urlparse.urlparse(rietveld_url).hostname |
300 authenticator = auth.get_authenticator_for_host(rietveld_host, auth_config) | 286 authenticator = auth.get_authenticator_for_host(rietveld_host, auth_config) |
301 http = authenticator.authorize(httplib2.Http()) | 287 http = authenticator.authorize(httplib2.Http()) |
302 http.force_exception_to_status_code = True | 288 http.force_exception_to_status_code = True |
303 issue_props = changelist.GetIssueProperties() | 289 issue_props = changelist.GetIssueProperties() |
304 issue = changelist.GetIssue() | 290 issue = changelist.GetIssue() |
305 patchset = changelist.GetMostRecentPatchset() | 291 patchset = changelist.GetMostRecentPatchset() |
306 properties = _get_properties_from_options(options) | 292 properties = _get_properties_from_options(options) |
(...skipping 4136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4443 group.add_option( | 4429 group.add_option( |
4444 "-b", "--bot", action="append", | 4430 "-b", "--bot", action="append", |
4445 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " | 4431 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " |
4446 "times to specify multiple builders. ex: " | 4432 "times to specify multiple builders. ex: " |
4447 "'-b win_rel -b win_layout'. See " | 4433 "'-b win_rel -b win_layout'. See " |
4448 "the try server waterfall for the builders name and the tests " | 4434 "the try server waterfall for the builders name and the tests " |
4449 "available.")) | 4435 "available.")) |
4450 group.add_option( | 4436 group.add_option( |
4451 "-m", "--master", default='', | 4437 "-m", "--master", default='', |
4452 help=("Specify a try master where to run the tries.")) | 4438 help=("Specify a try master where to run the tries.")) |
4453 group.add_option( "--luci", action='store_true') | |
4454 group.add_option( | 4439 group.add_option( |
4455 "-r", "--revision", | 4440 "-r", "--revision", |
4456 help="Revision to use for the try job; default: the " | 4441 help="Revision to use for the try job; default: the " |
4457 "revision will be determined by the try server; see " | 4442 "revision will be determined by the try server; see " |
4458 "its waterfall for more info") | 4443 "its waterfall for more info") |
4459 group.add_option( | 4444 group.add_option( |
4460 "-c", "--clobber", action="store_true", default=False, | 4445 "-c", "--clobber", action="store_true", default=False, |
4461 help="Force a clobber before building; e.g. don't do an " | 4446 help="Force a clobber before building; e.g. don't do an " |
4462 "incremental build") | 4447 "incremental build") |
4463 group.add_option( | 4448 group.add_option( |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4605 ' Instead send your job to the parent.\n' | 4590 ' Instead send your job to the parent.\n' |
4606 'Bot list: %s' % builders, file=sys.stderr) | 4591 'Bot list: %s' % builders, file=sys.stderr) |
4607 return 1 | 4592 return 1 |
4608 | 4593 |
4609 patchset = cl.GetMostRecentPatchset() | 4594 patchset = cl.GetMostRecentPatchset() |
4610 if patchset and patchset != cl.GetPatchset(): | 4595 if patchset and patchset != cl.GetPatchset(): |
4611 print( | 4596 print( |
4612 '\nWARNING Mismatch between local config and server. Did a previous ' | 4597 '\nWARNING Mismatch between local config and server. Did a previous ' |
4613 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' | 4598 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' |
4614 'Continuing using\npatchset %s.\n' % patchset) | 4599 'Continuing using\npatchset %s.\n' % patchset) |
4615 if options.luci: | 4600 if not options.use_rietveld: |
4616 trigger_luci_job(cl, masters, options) | |
4617 elif not options.use_rietveld: | |
4618 try: | 4601 try: |
4619 trigger_try_jobs(auth_config, cl, options, masters, 'git_cl_try') | 4602 trigger_try_jobs(auth_config, cl, options, masters, 'git_cl_try') |
4620 except BuildbucketResponseException as ex: | 4603 except BuildbucketResponseException as ex: |
4621 print('ERROR: %s' % ex) | 4604 print('ERROR: %s' % ex) |
4622 return 1 | 4605 return 1 |
4623 except Exception as e: | 4606 except Exception as e: |
4624 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc()) | 4607 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc()) |
4625 print('ERROR: Exception when trying to trigger tryjobs: %s\n%s' % | 4608 print('ERROR: Exception when trying to trigger tryjobs: %s\n%s' % |
4626 (e, stacktrace)) | 4609 (e, stacktrace)) |
4627 return 1 | 4610 return 1 |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5104 if __name__ == '__main__': | 5087 if __name__ == '__main__': |
5105 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5088 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5106 # unit testing. | 5089 # unit testing. |
5107 fix_encoding.fix_encoding() | 5090 fix_encoding.fix_encoding() |
5108 setup_color.init() | 5091 setup_color.init() |
5109 try: | 5092 try: |
5110 sys.exit(main(sys.argv[1:])) | 5093 sys.exit(main(sys.argv[1:])) |
5111 except KeyboardInterrupt: | 5094 except KeyboardInterrupt: |
5112 sys.stderr.write('interrupted\n') | 5095 sys.stderr.write('interrupted\n') |
5113 sys.exit(1) | 5096 sys.exit(1) |
OLD | NEW |