diff options
author | 2014-01-14 19:18:45 +0000 | |
---|---|---|
committer | 2014-01-14 19:18:45 +0000 | |
commit | 9f8e282901752e95e3b43059a19f08ea0a1a073e (patch) | |
tree | 998a58396a6c7e2ff05bc943e7efec1f5f2c8fb9 /tools/submit_try | |
parent | a6d46cb1bc5f8d901b07ecc1f10a39144ee1c345 (diff) |
submit_try: Obtain the list of trybots from the checked-in slaves.cfg
This should drastically speed up the script.
BUG=
R=epoger@google.com, rmistry@google.com
Author: borenet@google.com
Review URL: https://codereview.chromium.org/136683006
git-svn-id: http://skia.googlecode.com/svn/trunk@13071 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/submit_try')
-rwxr-xr-x | tools/submit_try | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/tools/submit_try b/tools/submit_try index a2d46fc14f..e371afb23a 100755 --- a/tools/submit_try +++ b/tools/submit_try @@ -35,13 +35,13 @@ CQ_BUILDERS = 'cq' # Alias which can be used to specify a regex to choose builders. REGEX = 'regex' -ALL_ALIASES = [ALL_BUILDERS, COMPILE_BUILDERS, CQ_BUILDERS, REGEX] +ALL_ALIASES = [ALL_BUILDERS, COMPILE_BUILDERS, REGEX, CQ_BUILDERS] GIT = 'git.bat' if os.name == 'nt' else 'git' -# Contact information for the build master. -SKIA_BUILD_MASTER_HOST = str(buildbot_globals.Get('public_master_host')) -SKIA_BUILD_MASTER_PORT = str(buildbot_globals.Get('public_external_port')) +# URL of the slaves.cfg file in the Skia buildbot sources. +SLAVES_CFG_URL = ('https://skia.googlesource.com/buildbot/+/master/' + 'master/slaves.cfg') # All try builders have this suffix. TRYBOT_SUFFIX = '-Trybot' @@ -103,27 +103,34 @@ def GetTryRepo(): 'defined in the %s file.' % codereview_settings_file) -def RetrieveTrybotList(json_filename): - """ Retrieve the list of known trybots from the build master, stripping - TRYBOT_SUFFIX from the name. """ - trybots = [] - connection = httplib.HTTPConnection(SKIA_BUILD_MASTER_HOST, - SKIA_BUILD_MASTER_PORT) - connection.request('GET', '/json/%s' % json_filename) - response = connection.getresponse() - builders = json.load(response) +def RetrieveTrybotList(): + """Retrieve the list of known trybots from the checked-in buildbot + configuration.""" + # Retrieve the slaves.cfg file from the repository. + slaves_cfg_text = buildbot_globals.retrieve_from_googlesource(SLAVES_CFG_URL) - for builder in builders: - if builder.endswith(TRYBOT_SUFFIX): - trybots.append(builder[:-len(TRYBOT_SUFFIX)]) - return trybots + # Execute the slaves.cfg file to obtain the list of slaves. + vars = {} + exec(slaves_cfg_text, vars) + slaves_cfg = vars['slaves'] + # Pull the list of known builders from the slaves list. + trybots = set() + for slave in slaves_cfg: + for builder in slave['builder']: + if not builder.endswith(TRYBOT_SUFFIX): + trybots.add(builder) -def ValidateArgs(argv, trybots, is_svn=True): + return list(trybots), vars['cq_trybots'] + + +def ValidateArgs(argv, trybots, cq_trybots, is_svn=True): """ Parse and validate command-line arguments. If the arguments are valid, returns a tuple of (<changelist name>, <list of trybots>). - trybots: A list of the known try builders. + trybots: list of strings; A list of the known try builders. + cq_trybots: list of strings; Trybots who get run by the commit queue. + is_svn: bool; whether or not we're in an svn checkout. """ class CollectedArgs(object): @@ -171,7 +178,9 @@ submit_try %s--bot <buildername> [<buildername> ...] if arg == '-h' or arg == '--help': Error() elif arg == '-l' or arg == '--list_bots': - format_args = ['\n '.join(sorted(trybots))] + ALL_ALIASES + format_args = ['\n '.join(sorted(trybots))] + \ + ALL_ALIASES + \ + ['\n '.join(sorted(cq_trybots))] print ( """ submit_try: Available builders:\n %s @@ -179,8 +188,8 @@ submit_try: Available builders:\n %s Can also use the following aliases to run on groups of builders- %s: Will run against all trybots. %s: Will run against all compile trybots. - %s: Will run against the same trybots as the commit queue. %s: You will be prompted to enter a regex to select builders with. + %s: Will run against the same trybots as the commit queue:\n %s """ % tuple(format_args)) sys.exit(0) @@ -208,7 +217,7 @@ Can also use the following aliases to run on groups of builders- elif bot == COMPILE_BUILDERS: using_bots = [t for t in trybots if t.startswith('Build')] elif bot == CQ_BUILDERS: - using_bots = RetrieveTrybotList(json_filename='cqtrybots') + using_bots = cq_trybots elif bot == REGEX: while True: regex = raw_input("Enter your trybot regex: ") @@ -303,13 +312,14 @@ def SubmitTryRequest(args, is_svn=True): def main(): # Retrieve the list of active try builders from the build master. - trybots = RetrieveTrybotList(json_filename='trybots') + trybots, cq_trybots = RetrieveTrybotList() # Determine if we're in an SVN checkout. is_svn = os.path.isdir('.svn') # Parse and validate the command-line arguments. - args = ValidateArgs(sys.argv[1:], trybots=trybots, is_svn=is_svn) + args = ValidateArgs(sys.argv[1:], trybots=trybots, cq_trybots=cq_trybots, + is_svn=is_svn) # Submit the try request. SubmitTryRequest(args, is_svn=is_svn) |