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

Side by Side Diff: tools/submit_try

Issue 136683006: submit_try: Obtain the list of trybots from the checked-in slaves.cfg (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 11 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
« tools/buildbot_globals.py ('K') | « tools/buildbot_globals.py ('k') | 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
(...skipping 17 matching lines...) Expand all
28 28
29 # Alias which can be used to run a try on every builder. 29 # Alias which can be used to run a try on every builder.
30 ALL_BUILDERS = 'all' 30 ALL_BUILDERS = 'all'
31 # Alias which can be used to run a try on all compile builders. 31 # Alias which can be used to run a try on all compile builders.
32 COMPILE_BUILDERS = 'compile' 32 COMPILE_BUILDERS = 'compile'
33 # Alias which can be used to run a try on all builders that are run in the CQ. 33 # Alias which can be used to run a try on all builders that are run in the CQ.
34 CQ_BUILDERS = 'cq' 34 CQ_BUILDERS = 'cq'
35 # Alias which can be used to specify a regex to choose builders. 35 # Alias which can be used to specify a regex to choose builders.
36 REGEX = 'regex' 36 REGEX = 'regex'
37 37
38 ALL_ALIASES = [ALL_BUILDERS, COMPILE_BUILDERS, CQ_BUILDERS, REGEX] 38 ALL_ALIASES = [ALL_BUILDERS, COMPILE_BUILDERS, REGEX, CQ_BUILDERS]
rmistry 2014/01/14 17:39:54 Why rearrange this? it was sorted before.
borenet 2014/01/14 18:00:05 See the format in the help string below. I wanted
39
40 # Contact information for the build master.
41 SKIA_BUILD_MASTER_HOST = str(buildbot_globals.Get('public_master_host'))
42 SKIA_BUILD_MASTER_PORT = str(buildbot_globals.Get('public_external_port'))
43 39
44 # All try builders have this suffix. 40 # All try builders have this suffix.
45 TRYBOT_SUFFIX = '-Trybot' 41 TRYBOT_SUFFIX = '-Trybot'
46 42
47 # String for matching the svn url of the try server inside codereview.settings. 43 # String for matching the svn url of the try server inside codereview.settings.
48 TRYSERVER_SVN_URL = 'TRYSERVER_SVN_URL: ' 44 TRYSERVER_SVN_URL = 'TRYSERVER_SVN_URL: '
49 45
50 # Strings used for matching svn config properties. 46 # Strings used for matching svn config properties.
51 URL_STR = 'URL' 47 URL_STR = 'URL'
52 REPO_ROOT_STR = 'Repository Root' 48 REPO_ROOT_STR = 'Repository Root'
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 codereview_settings_file = os.path.join(os.path.dirname(__file__), os.pardir, 90 codereview_settings_file = os.path.join(os.path.dirname(__file__), os.pardir,
95 'codereview.settings') 91 'codereview.settings')
96 with open(codereview_settings_file) as f: 92 with open(codereview_settings_file) as f:
97 for line in f: 93 for line in f:
98 if line.startswith(TRYSERVER_SVN_URL): 94 if line.startswith(TRYSERVER_SVN_URL):
99 return line[len(TRYSERVER_SVN_URL):].rstrip() 95 return line[len(TRYSERVER_SVN_URL):].rstrip()
100 raise Exception('Couldn\'t determine the TRYSERVER_SVN_URL. Make sure it is ' 96 raise Exception('Couldn\'t determine the TRYSERVER_SVN_URL. Make sure it is '
101 'defined in the %s file.' % codereview_settings_file) 97 'defined in the %s file.' % codereview_settings_file)
102 98
103 99
104 def RetrieveTrybotList(json_filename): 100 def RetrieveTrybotList():
105 """ Retrieve the list of known trybots from the build master, stripping 101 """Retrieve the list of known trybots from the checked-in buildbot
106 TRYBOT_SUFFIX from the name. """ 102 configuration."""
107 trybots = [] 103 # Retrieve the slaves.cfg file from the repository.
108 connection = httplib.HTTPConnection(SKIA_BUILD_MASTER_HOST, 104 slaves_cfg_url = ('https://skia.googlesource.com/buildbot/+/master/'
109 SKIA_BUILD_MASTER_PORT) 105 'master/slaves.cfg')
rmistry 2014/01/14 17:39:54 Can we make this a top-level constant.
borenet 2014/01/14 18:00:05 Done.
110 connection.request('GET', '/json/%s' % json_filename) 106 slaves_cfg_text = buildbot_globals.retrieve_from_googlesource(slaves_cfg_url)
111 response = connection.getresponse()
112 builders = json.load(response)
113 107
114 for builder in builders: 108 # Execute the slaves.cfg file to obtain the list of slaves.
115 if builder.endswith(TRYBOT_SUFFIX): 109 vars = {}
116 trybots.append(builder[:-len(TRYBOT_SUFFIX)]) 110 exec(slaves_cfg_text, vars)
117 return trybots 111 slaves_cfg = vars['slaves']
112
113 # Pull the list of known builders from the slaves list.
114 trybots = set()
115 for slave in slaves_cfg:
116 for builder in slave['builder']:
117 if not builder.endswith(TRYBOT_SUFFIX):
118 trybots.add(builder)
119
120 return list(trybots), vars['cq_trybots']
118 121
119 122
120 def ValidateArgs(argv, trybots, is_svn=True): 123 def ValidateArgs(argv, trybots, cq_trybots, is_svn=True):
121 """ Parse and validate command-line arguments. If the arguments are valid, 124 """ Parse and validate command-line arguments. If the arguments are valid,
122 returns a tuple of (<changelist name>, <list of trybots>). 125 returns a tuple of (<changelist name>, <list of trybots>).
123 126
124 trybots: A list of the known try builders. 127 trybots: list of strings; A list of the known try builders.
128 cq_trybots: list of strings; Trybots who get run by the commit queue.
129 is_svn: bool; whether or not we're in an svn checkout.
125 """ 130 """
126 131
127 class CollectedArgs(object): 132 class CollectedArgs(object):
128 def __init__(self, bots, changelist, revision): 133 def __init__(self, bots, changelist, revision):
129 self._bots = bots 134 self._bots = bots
130 self._changelist = changelist 135 self._changelist = changelist
131 self._revision = revision 136 self._revision = revision
132 137
133 @property 138 @property
134 def bots(self): 139 def bots(self):
(...skipping 27 matching lines...) Expand all
162 167
163 using_bots = None 168 using_bots = None
164 changelist = None 169 changelist = None
165 revision = None 170 revision = None
166 171
167 while argv: 172 while argv:
168 arg = argv.pop(0) 173 arg = argv.pop(0)
169 if arg == '-h' or arg == '--help': 174 if arg == '-h' or arg == '--help':
170 Error() 175 Error()
171 elif arg == '-l' or arg == '--list_bots': 176 elif arg == '-l' or arg == '--list_bots':
172 format_args = ['\n '.join(sorted(trybots))] + ALL_ALIASES 177 format_args = ['\n '.join(sorted(trybots))] + \
178 ALL_ALIASES + \
179 ['\n '.join(sorted(cq_trybots))]
173 print ( 180 print (
174 """ 181 """
175 submit_try: Available builders:\n %s 182 submit_try: Available builders:\n %s
176 183
177 Can also use the following aliases to run on groups of builders- 184 Can also use the following aliases to run on groups of builders-
178 %s: Will run against all trybots. 185 %s: Will run against all trybots.
179 %s: Will run against all compile trybots. 186 %s: Will run against all compile trybots.
180 %s: Will run against the same trybots as the commit queue.
181 %s: You will be prompted to enter a regex to select builders with. 187 %s: You will be prompted to enter a regex to select builders with.
188 %s: Will run against the same trybots as the commit queue:\n %s
182 189
183 """ % tuple(format_args)) 190 """ % tuple(format_args))
184 sys.exit(0) 191 sys.exit(0)
185 elif arg == '-b' or arg == '--bot': 192 elif arg == '-b' or arg == '--bot':
186 if using_bots: 193 if using_bots:
187 Error('--bot specified multiple times.') 194 Error('--bot specified multiple times.')
188 if len(argv) < 1: 195 if len(argv) < 1:
189 Error('You must specify a builder with "--bot".') 196 Error('You must specify a builder with "--bot".')
190 using_bots = [] 197 using_bots = []
191 while argv and not argv[0].startswith('-'): 198 while argv and not argv[0].startswith('-'):
192 for bot in argv.pop(0).split(','): 199 for bot in argv.pop(0).split(','):
193 if bot in ALL_ALIASES: 200 if bot in ALL_ALIASES:
194 if using_bots: 201 if using_bots:
195 Error('Cannot specify "%s" with additional builder names or ' 202 Error('Cannot specify "%s" with additional builder names or '
196 'aliases.' % bot) 203 'aliases.' % bot)
197 if bot == ALL_BUILDERS: 204 if bot == ALL_BUILDERS:
198 are_you_sure = raw_input('Running a try on every bot is very ' 205 are_you_sure = raw_input('Running a try on every bot is very '
199 'expensive. You may be able to get ' 206 'expensive. You may be able to get '
200 'enough information by running on a ' 207 'enough information by running on a '
201 'smaller set of bots. Are you sure you ' 208 'smaller set of bots. Are you sure you '
202 'want to run your try job on all of the ' 209 'want to run your try job on all of the '
203 'trybots? [y,n]: ') 210 'trybots? [y,n]: ')
204 if are_you_sure == 'y': 211 if are_you_sure == 'y':
205 using_bots = trybots 212 using_bots = trybots
206 elif bot == COMPILE_BUILDERS: 213 elif bot == COMPILE_BUILDERS:
207 using_bots = [t for t in trybots if t.startswith('Build')] 214 using_bots = [t for t in trybots if t.startswith('Build')]
208 elif bot == CQ_BUILDERS: 215 elif bot == CQ_BUILDERS:
209 using_bots = RetrieveTrybotList(json_filename='cqtrybots') 216 using_bots = cq_trybots
210 elif bot == REGEX: 217 elif bot == REGEX:
211 while True: 218 while True:
212 regex = raw_input("Enter your trybot regex: ") 219 regex = raw_input("Enter your trybot regex: ")
213 p = re.compile(regex) 220 p = re.compile(regex)
214 using_bots = [t for t in trybots if p.match(t)] 221 using_bots = [t for t in trybots if p.match(t)]
215 print '\n\nTrybots that match your regex:\n%s\n\n' % '\n'.join( 222 print '\n\nTrybots that match your regex:\n%s\n\n' % '\n'.join(
216 using_bots) 223 using_bots)
217 if raw_input('Re-enter regex? [y,n]: ') == 'n': 224 if raw_input('Re-enter regex? [y,n]: ') == 'n':
218 break 225 break
219 break 226 break
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 try_args.extend(['-r', args.revision]) 299 try_args.extend(['-r', args.revision])
293 300
294 # Submit the try request. 301 # Submit the try request.
295 trychange.TryChange(try_args, None, False) 302 trychange.TryChange(try_args, None, False)
296 finally: 303 finally:
297 shutil.rmtree(temp_dir) 304 shutil.rmtree(temp_dir)
298 305
299 306
300 def main(): 307 def main():
301 # Retrieve the list of active try builders from the build master. 308 # Retrieve the list of active try builders from the build master.
302 trybots = RetrieveTrybotList(json_filename='trybots') 309 trybots, cq_trybots = RetrieveTrybotList()
303 310
304 # Determine if we're in an SVN checkout. 311 # Determine if we're in an SVN checkout.
305 is_svn = os.path.isdir('.svn') 312 is_svn = os.path.isdir('.svn')
306 313
307 # Parse and validate the command-line arguments. 314 # Parse and validate the command-line arguments.
308 args = ValidateArgs(sys.argv[1:], trybots=trybots, is_svn=is_svn) 315 args = ValidateArgs(sys.argv[1:], trybots=trybots, cq_trybots=cq_trybots,
316 is_svn=is_svn)
309 317
310 # Submit the try request. 318 # Submit the try request.
311 SubmitTryRequest(args, is_svn=is_svn) 319 SubmitTryRequest(args, is_svn=is_svn)
312 320
313 321
314 if __name__ == '__main__': 322 if __name__ == '__main__':
315 sys.exit(main()) 323 sys.exit(main())
OLDNEW
« tools/buildbot_globals.py ('K') | « tools/buildbot_globals.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698