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

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

Powered by Google App Engine
This is Rietveld 408576698