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.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
9 | 9 |
10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
(...skipping 21 matching lines...) Expand all Loading... | |
32 | 32 |
33 try: | 33 try: |
34 import readline # pylint: disable=F0401,W0611 | 34 import readline # pylint: disable=F0401,W0611 |
35 except ImportError: | 35 except ImportError: |
36 pass | 36 pass |
37 | 37 |
38 from third_party import colorama | 38 from third_party import colorama |
39 from third_party import httplib2 | 39 from third_party import httplib2 |
40 from third_party import upload | 40 from third_party import upload |
41 import auth | 41 import auth |
42 from luci_hacks import trigger_luci_job as luci_trigger | |
42 import breakpad # pylint: disable=W0611 | 43 import breakpad # pylint: disable=W0611 |
43 import clang_format | 44 import clang_format |
44 import dart_format | 45 import dart_format |
45 import fix_encoding | 46 import fix_encoding |
46 import gclient_utils | 47 import gclient_utils |
47 import git_common | 48 import git_common |
48 from git_footers import get_footer_svn_id | 49 from git_footers import get_footer_svn_id |
49 import owners | 50 import owners |
50 import owners_finder | 51 import owners_finder |
51 import presubmit_support | 52 import presubmit_support |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 name, while the developers always use shortened master name | 222 name, while the developers always use shortened master name |
222 (tryserver.chromium.linux) by stripping off the prefix 'master.'. This | 223 (tryserver.chromium.linux) by stripping off the prefix 'master.'. This |
223 function does the conversion for buildbucket migration. | 224 function does the conversion for buildbucket migration. |
224 """ | 225 """ |
225 prefix = 'master.' | 226 prefix = 'master.' |
226 if master.startswith(prefix): | 227 if master.startswith(prefix): |
227 return master | 228 return master |
228 return '%s%s' % (prefix, master) | 229 return '%s%s' % (prefix, master) |
229 | 230 |
230 | 231 |
232 def trigger_luci_job(changelist, masters, options): | |
233 """Send a job to run on LUCI.""" | |
234 try_py = os.path.join( | |
235 os.path.dirname( | |
236 os.path.abspath(__file__)), 'luci_hacks', 'luci_recipe_run.py') | |
237 issue_props = changelist.GetIssueProperties() | |
238 issue = changelist.GetIssue() | |
239 patchset = changelist.GetMostRecentPatchset() | |
240 for _, builders_and_tests in sorted(masters.iteritems()): | |
estaab
2015/09/15 23:05:14
itervalues()
Ryan Tseng
2015/09/17 23:39:23
Done.
| |
241 for builder, _ in sorted(builders_and_tests.iteritems()): | |
estaab
2015/09/15 23:05:14
iterkeys()
Ryan Tseng
2015/09/17 23:39:23
Done.
| |
242 luci_trigger.trigger( | |
243 builder, 'HEAD', issue, patchset, issue_props['project']) | |
244 | |
245 | |
231 def trigger_try_jobs(auth_config, changelist, options, masters, category, | 246 def trigger_try_jobs(auth_config, changelist, options, masters, category, |
232 override_properties=None): | 247 override_properties=None): |
233 rietveld_url = settings.GetDefaultServerUrl() | 248 rietveld_url = settings.GetDefaultServerUrl() |
234 rietveld_host = urlparse.urlparse(rietveld_url).hostname | 249 rietveld_host = urlparse.urlparse(rietveld_url).hostname |
235 authenticator = auth.get_authenticator_for_host(rietveld_host, auth_config) | 250 authenticator = auth.get_authenticator_for_host(rietveld_host, auth_config) |
236 http = authenticator.authorize(httplib2.Http()) | 251 http = authenticator.authorize(httplib2.Http()) |
237 http.force_exception_to_status_code = True | 252 http.force_exception_to_status_code = True |
238 issue_props = changelist.GetIssueProperties() | 253 issue_props = changelist.GetIssueProperties() |
239 issue = changelist.GetIssue() | 254 issue = changelist.GetIssue() |
240 patchset = changelist.GetMostRecentPatchset() | 255 patchset = changelist.GetMostRecentPatchset() |
(...skipping 2811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3052 group.add_option( | 3067 group.add_option( |
3053 "-b", "--bot", action="append", | 3068 "-b", "--bot", action="append", |
3054 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " | 3069 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " |
3055 "times to specify multiple builders. ex: " | 3070 "times to specify multiple builders. ex: " |
3056 "'-b win_rel -b win_layout'. See " | 3071 "'-b win_rel -b win_layout'. See " |
3057 "the try server waterfall for the builders name and the tests " | 3072 "the try server waterfall for the builders name and the tests " |
3058 "available.")) | 3073 "available.")) |
3059 group.add_option( | 3074 group.add_option( |
3060 "-m", "--master", default='', | 3075 "-m", "--master", default='', |
3061 help=("Specify a try master where to run the tries.")) | 3076 help=("Specify a try master where to run the tries.")) |
3077 group.add_option( "--luci", action='store_true') | |
3062 group.add_option( | 3078 group.add_option( |
3063 "-r", "--revision", | 3079 "-r", "--revision", |
3064 help="Revision to use for the try job; default: the " | 3080 help="Revision to use for the try job; default: the " |
3065 "revision will be determined by the try server; see " | 3081 "revision will be determined by the try server; see " |
3066 "its waterfall for more info") | 3082 "its waterfall for more info") |
3067 group.add_option( | 3083 group.add_option( |
3068 "-c", "--clobber", action="store_true", default=False, | 3084 "-c", "--clobber", action="store_true", default=False, |
3069 help="Force a clobber before building; e.g. don't do an " | 3085 help="Force a clobber before building; e.g. don't do an " |
3070 "incremental build") | 3086 "incremental build") |
3071 group.add_option( | 3087 group.add_option( |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3170 'Instead send your job to the parent.\n' | 3186 'Instead send your job to the parent.\n' |
3171 'Bot list: %s' % builders) | 3187 'Bot list: %s' % builders) |
3172 return 1 | 3188 return 1 |
3173 | 3189 |
3174 patchset = cl.GetMostRecentPatchset() | 3190 patchset = cl.GetMostRecentPatchset() |
3175 if patchset and patchset != cl.GetPatchset(): | 3191 if patchset and patchset != cl.GetPatchset(): |
3176 print( | 3192 print( |
3177 '\nWARNING Mismatch between local config and server. Did a previous ' | 3193 '\nWARNING Mismatch between local config and server. Did a previous ' |
3178 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' | 3194 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' |
3179 'Continuing using\npatchset %s.\n' % patchset) | 3195 'Continuing using\npatchset %s.\n' % patchset) |
3180 if not options.use_rietveld: | 3196 if options.luci: |
3197 trigger_luci_job(cl, masters, options) | |
3198 elif not options.use_rietveld: | |
3181 try: | 3199 try: |
3182 trigger_try_jobs(auth_config, cl, options, masters, 'git_cl_try') | 3200 trigger_try_jobs(auth_config, cl, options, masters, 'git_cl_try') |
3183 except BuildbucketResponseException as ex: | 3201 except BuildbucketResponseException as ex: |
3184 print 'ERROR: %s' % ex | 3202 print 'ERROR: %s' % ex |
3185 return 1 | 3203 return 1 |
3186 except Exception as e: | 3204 except Exception as e: |
3187 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc()) | 3205 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc()) |
3188 print 'ERROR: Exception when trying to trigger tryjobs: %s\n%s' % ( | 3206 print 'ERROR: Exception when trying to trigger tryjobs: %s\n%s' % ( |
3189 e, stacktrace) | 3207 e, stacktrace) |
3190 return 1 | 3208 return 1 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3558 if __name__ == '__main__': | 3576 if __name__ == '__main__': |
3559 # These affect sys.stdout so do it outside of main() to simplify mocks in | 3577 # These affect sys.stdout so do it outside of main() to simplify mocks in |
3560 # unit testing. | 3578 # unit testing. |
3561 fix_encoding.fix_encoding() | 3579 fix_encoding.fix_encoding() |
3562 colorama.init() | 3580 colorama.init() |
3563 try: | 3581 try: |
3564 sys.exit(main(sys.argv[1:])) | 3582 sys.exit(main(sys.argv[1:])) |
3565 except KeyboardInterrupt: | 3583 except KeyboardInterrupt: |
3566 sys.stderr.write('interrupted\n') | 3584 sys.stderr.write('interrupted\n') |
3567 sys.exit(1) | 3585 sys.exit(1) |
OLD | NEW |