Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Side by Side Diff: git_cl.py

Issue 1132913005: Make buildbucket default for git cl try (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: rename option Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 DEFAULT_SERVER = 'https://codereview.appspot.com' 60 DEFAULT_SERVER = 'https://codereview.appspot.com'
61 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' 61 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
62 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' 62 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
63 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit' 63 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit'
64 CHANGE_ID = 'Change-Id:' 64 CHANGE_ID = 'Change-Id:'
65 REFS_THAT_ALIAS_TO_OTHER_REFS = { 65 REFS_THAT_ALIAS_TO_OTHER_REFS = {
66 'refs/remotes/origin/lkgr': 'refs/remotes/origin/master', 66 'refs/remotes/origin/lkgr': 'refs/remotes/origin/master',
67 'refs/remotes/origin/lkcr': 'refs/remotes/origin/master', 67 'refs/remotes/origin/lkcr': 'refs/remotes/origin/master',
68 } 68 }
69 69
70 # Buildbucket-related constants
71 BUILDBUCKET_HOST = 'cr-buildbucket.appspot.com'
72
73 # Valid extensions for files we want to lint. 70 # Valid extensions for files we want to lint.
74 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)" 71 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)"
75 DEFAULT_LINT_IGNORE_REGEX = r"$^" 72 DEFAULT_LINT_IGNORE_REGEX = r"$^"
76 73
77 # Shortcut since it quickly becomes redundant. 74 # Shortcut since it quickly becomes redundant.
78 Fore = colorama.Fore 75 Fore = colorama.Fore
79 76
80 # Initialized in main() 77 # Initialized in main()
81 settings = None 78 settings = None
82 79
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 rietveld_host = urlparse.urlparse(rietveld_url).hostname 234 rietveld_host = urlparse.urlparse(rietveld_url).hostname
238 authenticator = auth.get_authenticator_for_host(rietveld_host, auth_config) 235 authenticator = auth.get_authenticator_for_host(rietveld_host, auth_config)
239 http = authenticator.authorize(httplib2.Http()) 236 http = authenticator.authorize(httplib2.Http())
240 http.force_exception_to_status_code = True 237 http.force_exception_to_status_code = True
241 issue_props = changelist.GetIssueProperties() 238 issue_props = changelist.GetIssueProperties()
242 issue = changelist.GetIssue() 239 issue = changelist.GetIssue()
243 patchset = changelist.GetMostRecentPatchset() 240 patchset = changelist.GetMostRecentPatchset()
244 241
245 buildbucket_put_url = ( 242 buildbucket_put_url = (
246 'https://{hostname}/_ah/api/buildbucket/v1/builds/batch'.format( 243 'https://{hostname}/_ah/api/buildbucket/v1/builds/batch'.format(
247 hostname=BUILDBUCKET_HOST)) 244 hostname=options.buildbucket_host))
248 buildset = 'patch/rietveld/{hostname}/{issue}/{patch}'.format( 245 buildset = 'patch/rietveld/{hostname}/{issue}/{patch}'.format(
249 hostname=rietveld_host, 246 hostname=rietveld_host,
250 issue=issue, 247 issue=issue,
251 patch=patchset) 248 patch=patchset)
252 249
253 batch_req_body = {'builds': []} 250 batch_req_body = {'builds': []}
254 print_text = [] 251 print_text = []
255 print_text.append('Tried jobs on:') 252 print_text.append('Tried jobs on:')
256 for master, builders_and_tests in sorted(masters.iteritems()): 253 for master, builders_and_tests in sorted(masters.iteritems()):
257 print_text.append('Master: %s' % master) 254 print_text.append('Master: %s' % master)
(...skipping 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after
3043 3040
3044 print "The tree is %s" % status 3041 print "The tree is %s" % status
3045 print 3042 print
3046 print GetTreeStatusReason() 3043 print GetTreeStatusReason()
3047 if status != 'open': 3044 if status != 'open':
3048 return 1 3045 return 1
3049 return 0 3046 return 0
3050 3047
3051 3048
3052 def CMDtry(parser, args): 3049 def CMDtry(parser, args):
3053 """Triggers a try job through Rietveld.""" 3050 """Triggers a try job through BuildBucket."""
3054 group = optparse.OptionGroup(parser, "Try job options") 3051 group = optparse.OptionGroup(parser, "Try job options")
3055 group.add_option( 3052 group.add_option(
3056 "-b", "--bot", action="append", 3053 "-b", "--bot", action="append",
3057 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " 3054 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple "
3058 "times to specify multiple builders. ex: " 3055 "times to specify multiple builders. ex: "
3059 "'-b win_rel -b win_layout'. See " 3056 "'-b win_rel -b win_layout'. See "
3060 "the try server waterfall for the builders name and the tests " 3057 "the try server waterfall for the builders name and the tests "
3061 "available.")) 3058 "available."))
3062 group.add_option( 3059 group.add_option(
3063 "-m", "--master", default='', 3060 "-m", "--master", default='',
3064 help=("Specify a try master where to run the tries.")) 3061 help=("Specify a try master where to run the tries."))
3065 group.add_option( 3062 group.add_option(
3066 "-r", "--revision", 3063 "-r", "--revision",
3067 help="Revision to use for the try job; default: the " 3064 help="Revision to use for the try job; default: the "
3068 "revision will be determined by the try server; see " 3065 "revision will be determined by the try server; see "
3069 "its waterfall for more info") 3066 "its waterfall for more info")
3070 group.add_option( 3067 group.add_option(
3071 "-c", "--clobber", action="store_true", default=False, 3068 "-c", "--clobber", action="store_true", default=False,
3072 help="Force a clobber before building; e.g. don't do an " 3069 help="Force a clobber before building; e.g. don't do an "
3073 "incremental build") 3070 "incremental build")
3074 group.add_option( 3071 group.add_option(
3075 "--project", 3072 "--project",
3076 help="Override which project to use. Projects are defined " 3073 help="Override which project to use. Projects are defined "
3077 "server-side to define what default bot set to use") 3074 "server-side to define what default bot set to use")
3078 group.add_option( 3075 group.add_option(
3079 "-n", "--name", help="Try job name; default to current branch name") 3076 "-n", "--name", help="Try job name; default to current branch name")
3080 group.add_option( 3077 group.add_option(
3081 "--use-buildbucket", action="store_true", default=False, 3078 "--use-rietveld", action="store_true", default=False,
3082 help="Use buildbucket to trigger try jobs.") 3079 help="Use Rietveld to trigger try jobs.")
3080 group.add_option(
3081 "--buildbucket-host", default='cr-buildbucket.appspot.com',
3082 help="Host of buildbucket. The default host is %default.")
3083 parser.add_option_group(group) 3083 parser.add_option_group(group)
3084 auth.add_auth_options(parser) 3084 auth.add_auth_options(parser)
3085 options, args = parser.parse_args(args) 3085 options, args = parser.parse_args(args)
3086 auth_config = auth.extract_auth_config_from_options(options) 3086 auth_config = auth.extract_auth_config_from_options(options)
3087 3087
3088 if args: 3088 if args:
3089 parser.error('Unknown arguments: %s' % args) 3089 parser.error('Unknown arguments: %s' % args)
3090 3090
3091 cl = Changelist(auth_config=auth_config) 3091 cl = Changelist(auth_config=auth_config)
3092 if not cl.GetIssue(): 3092 if not cl.GetIssue():
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 'Instead send your job to the parent.\n' 3170 'Instead send your job to the parent.\n'
3171 'Bot list: %s' % builders) 3171 'Bot list: %s' % builders)
3172 return 1 3172 return 1
3173 3173
3174 patchset = cl.GetMostRecentPatchset() 3174 patchset = cl.GetMostRecentPatchset()
3175 if patchset and patchset != cl.GetPatchset(): 3175 if patchset and patchset != cl.GetPatchset():
3176 print( 3176 print(
3177 '\nWARNING Mismatch between local config and server. Did a previous ' 3177 '\nWARNING Mismatch between local config and server. Did a previous '
3178 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' 3178 'upload fail?\ngit-cl try always uses latest patchset from rietveld. '
3179 'Continuing using\npatchset %s.\n' % patchset) 3179 'Continuing using\npatchset %s.\n' % patchset)
3180 if options.use_buildbucket: 3180 if not options.use_rietveld:
3181 try: 3181 try:
3182 trigger_try_jobs(auth_config, cl, options, masters, 'git_cl_try') 3182 trigger_try_jobs(auth_config, cl, options, masters, 'git_cl_try')
3183 except BuildbucketResponseException as ex: 3183 except BuildbucketResponseException as ex:
3184 print 'ERROR: %s' % ex 3184 print 'ERROR: %s' % ex
3185 return 1 3185 return 1
3186 except Exception as e: 3186 except Exception as e:
3187 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc()) 3187 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc())
3188 print 'ERROR: Exception when trying to trigger tryjobs: %s\n%s' % ( 3188 print 'ERROR: Exception when trying to trigger tryjobs: %s\n%s' % (
3189 e, stacktrace) 3189 e, stacktrace)
3190 return 1 3190 return 1
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
3558 if __name__ == '__main__': 3558 if __name__ == '__main__':
3559 # These affect sys.stdout so do it outside of main() to simplify mocks in 3559 # These affect sys.stdout so do it outside of main() to simplify mocks in
3560 # unit testing. 3560 # unit testing.
3561 fix_encoding.fix_encoding() 3561 fix_encoding.fix_encoding()
3562 colorama.init() 3562 colorama.init()
3563 try: 3563 try:
3564 sys.exit(main(sys.argv[1:])) 3564 sys.exit(main(sys.argv[1:]))
3565 except KeyboardInterrupt: 3565 except KeyboardInterrupt:
3566 sys.stderr.write('interrupted\n') 3566 sys.stderr.write('interrupted\n')
3567 sys.exit(1) 3567 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698