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

Side by Side Diff: tools/submit_try

Issue 13493012: Introduce aliases and regex in submit_try (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 7
8 """ 8 """
9 submit_try: Submit a try request. 9 submit_try: Submit a try request.
10 10
11 This is a thin wrapper around the try request utilities in depot_tools which 11 This is a thin wrapper around the try request utilities in depot_tools which
12 adds some validation and supports both git and svn. 12 adds some validation and supports both git and svn.
13 """ 13 """
14 14
15 15
16 import httplib 16 import httplib
17 import json 17 import json
18 import os 18 import os
19 import re
19 import subprocess 20 import subprocess
20 import svn 21 import svn
21 import sys 22 import sys
22 23
23 24
24 GLOBAL_VARIABLES = json.loads(svn.Cat('http://skia.googlecode.com/svn/' 25 GLOBAL_VARIABLES = json.loads(svn.Cat('http://skia.googlecode.com/svn/'
25 'buildbot/site_config/' 26 'buildbot/site_config/'
26 'global_variables.json')) 27 'global_variables.json'))
27 28
28 29
29 def GetGlobalVariable(var_name): 30 def GetGlobalVariable(var_name):
30 return GLOBAL_VARIABLES[var_name]['value'] 31 return GLOBAL_VARIABLES[var_name]['value']
31 32
32 33
33 # Alias which can be used to run a try on every builder. 34 # Alias which can be used to run a try on every builder.
34 ALL_BUILDERS = 'all' 35 ALL_BUILDERS = 'all'
36 # Alias which can be used to run a try on all compile builders.
37 COMPILE_BUILDERS = 'compile'
38 # Alias which can be used to run a try on all builders that are run in the CQ.
39 CQ_BUILDERS = 'cq'
40 # Alias which can be used to specify a regex to choose builders.
41 REGEX = 'regex'
42
43 ALL_ALIASES = [ALL_BUILDERS, COMPILE_BUILDERS, CQ_BUILDERS, REGEX]
35 44
36 # Contact information for the build master. 45 # Contact information for the build master.
37 SKIA_BUILD_MASTER_HOST = str(GetGlobalVariable('master_host')) 46 SKIA_BUILD_MASTER_HOST = str(GetGlobalVariable('master_host'))
38 SKIA_BUILD_MASTER_PORT = str(GetGlobalVariable('external_port')) 47 SKIA_BUILD_MASTER_PORT = str(GetGlobalVariable('external_port'))
39 48
40 # All try builders have this suffix. 49 # All try builders have this suffix.
41 TRYBOT_SUFFIX = '_Trybot' 50 TRYBOT_SUFFIX = '_Trybot'
42 51
43 # Location of the codereview.settings file in the Skia repo. 52 # Location of the codereview.settings file in the Skia repo.
44 SKIA_URL = 'skia.googlecode.com' 53 SKIA_URL = 'skia.googlecode.com'
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 connection = httplib.HTTPConnection(SKIA_URL) 104 connection = httplib.HTTPConnection(SKIA_URL)
96 connection.request('GET', CODEREVIEW_SETTINGS) 105 connection.request('GET', CODEREVIEW_SETTINGS)
97 content = connection.getresponse().read() 106 content = connection.getresponse().read()
98 for line in content.split('\n'): 107 for line in content.split('\n'):
99 if line.startswith(TRYSERVER_SVN_URL): 108 if line.startswith(TRYSERVER_SVN_URL):
100 return line[len(TRYSERVER_SVN_URL):].rstrip() 109 return line[len(TRYSERVER_SVN_URL):].rstrip()
101 raise Exception('Couldn\'t determine the TRYSERVER_SVN_URL. Make sure it is ' 110 raise Exception('Couldn\'t determine the TRYSERVER_SVN_URL. Make sure it is '
102 'defined in the %s file.' % CODEREVIEW_SETTINGS) 111 'defined in the %s file.' % CODEREVIEW_SETTINGS)
103 112
104 113
105 def RetrieveTrybotList(): 114 def RetrieveTrybotList(json_filename):
106 """ Retrieve the list of known trybots from the build master, stripping 115 """ Retrieve the list of known trybots from the build master, stripping
107 TRYBOT_SUFFIX from the name. """ 116 TRYBOT_SUFFIX from the name. """
108 trybots = [] 117 trybots = []
109 connection = httplib.HTTPConnection(SKIA_BUILD_MASTER_HOST, 118 connection = httplib.HTTPConnection(SKIA_BUILD_MASTER_HOST,
110 SKIA_BUILD_MASTER_PORT) 119 SKIA_BUILD_MASTER_PORT)
111 connection.request('GET', '/json/builders') 120 connection.request('GET', '/json/%s' % json_filename)
112 response = connection.getresponse() 121 response = connection.getresponse()
113 builders = json.load(response) 122 builders = json.load(response)
114 123
115 for builder in builders: 124 for builder in builders:
116 if builder.endswith(TRYBOT_SUFFIX): 125 if builder.endswith(TRYBOT_SUFFIX):
117 trybots.append(builder[:-len(TRYBOT_SUFFIX)]) 126 trybots.append(builder[:-len(TRYBOT_SUFFIX)])
118 return trybots 127 return trybots
119 128
120 129
121 def ValidateArgs(argv, trybots, is_svn=True): 130 def ValidateArgs(argv, trybots, is_svn=True):
(...skipping 19 matching lines...) Expand all
141 return self._changelist 150 return self._changelist
142 151
143 @property 152 @property
144 def revision(self): 153 def revision(self):
145 return self._revision 154 return self._revision
146 155
147 usage = ( 156 usage = (
148 """submit_try: Submit a try request. 157 """submit_try: Submit a try request.
149 submit_try %s--bot <buildername> [<buildername> ...] 158 submit_try %s--bot <buildername> [<buildername> ...]
150 159
151 -b, --bot Builder on which to run the try. Required. 160 -b, --bot Builder(s) or Alias on which to run the try. Required.
161 Allowed aliases: %s
152 -h, --help Show this message. 162 -h, --help Show this message.
153 -r <revision#> Revision from which to run the try. 163 -r <revision#> Revision from which to run the try.
154 -l, --list_bots List the available try builders and exit. 164 -l, --list_bots List the available try builders and aliases and exit.
155 """ % ('<changelist> ' if is_svn else '')) 165 """ % ('<changelist> ' if is_svn else '', ALL_ALIASES))
156 166
157 def Error(msg=None): 167 def Error(msg=None):
158 if msg: 168 if msg:
159 print msg 169 print msg
160 print usage 170 print usage
161 sys.exit(1) 171 sys.exit(1)
162 172
163 using_bots = None 173 using_bots = None
164 changelist = None 174 changelist = None
165 revision = None 175 revision = None
166 176
167 while argv: 177 while argv:
168 arg = argv.pop(0) 178 arg = argv.pop(0)
169 if arg == '-h' or arg == '--help': 179 if arg == '-h' or arg == '--help':
170 Error() 180 Error()
171 elif arg == '-l' or arg == '--list_bots': 181 elif arg == '-l' or arg == '--list_bots':
172 print 'submit_try: Available builders:\n %s' % '\n '.join(trybots) 182 format_args = ['\n '.join(trybots)] + ALL_ALIASES
183 print (
184 """
185 submit_try: Available builders:\n %s
186
187 Can also use the following aliases to run on groups of builders-
188 %s: Will run against all trybots.
189 %s: Will run against all compile trybots.
190 %s: Will run against the same trybots as the commit queue.
191 %s: You will be prompted to enter a regex to select builders with.
192
193 """ % tuple(format_args))
173 sys.exit(0) 194 sys.exit(0)
174 elif arg == '-b' or arg == '--bot': 195 elif arg == '-b' or arg == '--bot':
175 if using_bots: 196 if using_bots:
176 Error('--bot specified multiple times.') 197 Error('--bot specified multiple times.')
177 if len(argv) < 1: 198 if len(argv) < 1:
178 Error('You must specify a builder with "--bot".') 199 Error('You must specify a builder with "--bot".')
179 using_bots = [] 200 using_bots = []
180 while argv and not argv[0].startswith('-'): 201 while argv and not argv[0].startswith('-'):
181 for bot in argv.pop(0).split(','): 202 for bot in argv.pop(0).split(','):
182 if bot == ALL_BUILDERS: 203 if bot in ALL_ALIASES:
183 if using_bots: 204 if using_bots:
184 Error('Cannot specify "all" with additional builder names.') 205 Error('Cannot specify "%s" with additional builder names or '
185 using_bots = trybots 206 'aliases.' % bot)
207 if bot == ALL_BUILDERS:
208 using_bots = trybots
209 elif bot == COMPILE_BUILDERS:
210 using_bots = [t for t in trybots if '_Compile_' in t]
211 elif bot == CQ_BUILDERS:
212 using_bots = RetrieveTrybotList(json_filename='cqtrybots')
213 elif bot == REGEX:
214 while True:
215 regex = raw_input("Enter your trybot regex: ")
216 p = re.compile(regex)
217 using_bots = [t for t in trybots if p.match(t)]
218 print '\n\nTrybots that match your regex:\n%s\n\n' % '\n'.join(
219 using_bots)
220 if raw_input('Re-enter regex? [y,n]: ') == 'n':
221 break
186 break 222 break
187 else: 223 else:
188 if not bot in trybots: 224 if not bot in trybots:
189 Error('Unrecognized builder: %s' % bot) 225 Error('Unrecognized builder: %s' % bot)
190 using_bots.append(bot) 226 using_bots.append(bot)
191 elif arg == '-r': 227 elif arg == '-r':
192 if len(argv) < 1: 228 if len(argv) < 1:
193 Error('You must specify a revision with "-r".') 229 Error('You must specify a revision with "-r".')
194 revision = argv.pop(0) 230 revision = argv.pop(0)
195 else: 231 else:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 '--svn_repo', GetTryRepo(), 277 '--svn_repo', GetTryRepo(),
242 '--root', GetCheckoutRoot(is_svn), 278 '--root', GetCheckoutRoot(is_svn),
243 '--bot', botlist] 279 '--bot', botlist]
244 if args.revision: 280 if args.revision:
245 try_args.extend(['-r', args.revision]) 281 try_args.extend(['-r', args.revision])
246 trychange.TryChange(try_args, None, False) 282 trychange.TryChange(try_args, None, False)
247 283
248 284
249 def main(): 285 def main():
250 # Retrieve the list of active try builders from the build master. 286 # Retrieve the list of active try builders from the build master.
251 trybots = RetrieveTrybotList() 287 trybots = RetrieveTrybotList(json_filename='trybots')
252 288
253 # Determine if we're in an SVN checkout. 289 # Determine if we're in an SVN checkout.
254 is_svn = os.path.isdir('.svn') 290 is_svn = os.path.isdir('.svn')
255 291
256 # Parse and validate the command-line arguments. 292 # Parse and validate the command-line arguments.
257 args = ValidateArgs(sys.argv[1:], trybots=trybots, is_svn=is_svn) 293 args = ValidateArgs(sys.argv[1:], trybots=trybots, is_svn=is_svn)
258 294
259 # Submit the try request. 295 # Submit the try request.
260 SubmitTryRequest(args, is_svn=is_svn) 296 SubmitTryRequest(args, is_svn=is_svn)
261 297
262 298
263 if __name__ == '__main__': 299 if __name__ == '__main__':
264 sys.exit(main()) 300 sys.exit(main())
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