зеркало из https://github.com/mozilla/moz-skia.git
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
This commit is contained in:
Родитель
a6d46cb1bc
Коммит
9f8e282901
|
@ -13,6 +13,7 @@ from contextlib import closing
|
||||||
|
|
||||||
import HTMLParser
|
import HTMLParser
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
import svn
|
import svn
|
||||||
import sys
|
import sys
|
||||||
import urllib2
|
import urllib2
|
||||||
|
@ -61,12 +62,13 @@ def retrieve_from_googlesource(url):
|
||||||
"""
|
"""
|
||||||
with closing(urllib2.urlopen(url)) as f:
|
with closing(urllib2.urlopen(url)) as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
pre_open = '<pre class="git-blob prettyprint linenums lang-json">'
|
pre_open = '<pre class="git-blob prettyprint linenums lang-(\w+)">'
|
||||||
pre_close = '</pre>'
|
pre_close = '</pre>'
|
||||||
start_index = contents.find(pre_open)
|
matched_tag = re.search(pre_open, contents).group()
|
||||||
|
start_index = contents.find(matched_tag)
|
||||||
end_index = contents.find(pre_close)
|
end_index = contents.find(pre_close)
|
||||||
parser = HTMLParser.HTMLParser()
|
parser = HTMLParser.HTMLParser()
|
||||||
return parser.unescape(contents[start_index + len(pre_open):end_index])
|
return parser.unescape(contents[start_index + len(matched_tag):end_index])
|
||||||
|
|
||||||
|
|
||||||
def Get(var_name):
|
def Get(var_name):
|
||||||
|
|
|
@ -35,13 +35,13 @@ CQ_BUILDERS = 'cq'
|
||||||
# Alias which can be used to specify a regex to choose builders.
|
# Alias which can be used to specify a regex to choose builders.
|
||||||
REGEX = 'regex'
|
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'
|
GIT = 'git.bat' if os.name == 'nt' else 'git'
|
||||||
|
|
||||||
# Contact information for the build master.
|
# URL of the slaves.cfg file in the Skia buildbot sources.
|
||||||
SKIA_BUILD_MASTER_HOST = str(buildbot_globals.Get('public_master_host'))
|
SLAVES_CFG_URL = ('https://skia.googlesource.com/buildbot/+/master/'
|
||||||
SKIA_BUILD_MASTER_PORT = str(buildbot_globals.Get('public_external_port'))
|
'master/slaves.cfg')
|
||||||
|
|
||||||
# All try builders have this suffix.
|
# All try builders have this suffix.
|
||||||
TRYBOT_SUFFIX = '-Trybot'
|
TRYBOT_SUFFIX = '-Trybot'
|
||||||
|
@ -103,27 +103,34 @@ def GetTryRepo():
|
||||||
'defined in the %s file.' % codereview_settings_file)
|
'defined in the %s file.' % codereview_settings_file)
|
||||||
|
|
||||||
|
|
||||||
def RetrieveTrybotList(json_filename):
|
def RetrieveTrybotList():
|
||||||
""" Retrieve the list of known trybots from the build master, stripping
|
"""Retrieve the list of known trybots from the checked-in buildbot
|
||||||
TRYBOT_SUFFIX from the name. """
|
configuration."""
|
||||||
trybots = []
|
# Retrieve the slaves.cfg file from the repository.
|
||||||
connection = httplib.HTTPConnection(SKIA_BUILD_MASTER_HOST,
|
slaves_cfg_text = buildbot_globals.retrieve_from_googlesource(SLAVES_CFG_URL)
|
||||||
SKIA_BUILD_MASTER_PORT)
|
|
||||||
connection.request('GET', '/json/%s' % json_filename)
|
|
||||||
response = connection.getresponse()
|
|
||||||
builders = json.load(response)
|
|
||||||
|
|
||||||
for builder in builders:
|
# Execute the slaves.cfg file to obtain the list of slaves.
|
||||||
if builder.endswith(TRYBOT_SUFFIX):
|
vars = {}
|
||||||
trybots.append(builder[:-len(TRYBOT_SUFFIX)])
|
exec(slaves_cfg_text, vars)
|
||||||
return trybots
|
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)
|
||||||
|
|
||||||
|
return list(trybots), vars['cq_trybots']
|
||||||
|
|
||||||
|
|
||||||
def ValidateArgs(argv, trybots, is_svn=True):
|
def ValidateArgs(argv, trybots, cq_trybots, is_svn=True):
|
||||||
""" Parse and validate command-line arguments. If the arguments are valid,
|
""" Parse and validate command-line arguments. If the arguments are valid,
|
||||||
returns a tuple of (<changelist name>, <list of trybots>).
|
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):
|
class CollectedArgs(object):
|
||||||
|
@ -171,7 +178,9 @@ submit_try %s--bot <buildername> [<buildername> ...]
|
||||||
if arg == '-h' or arg == '--help':
|
if arg == '-h' or arg == '--help':
|
||||||
Error()
|
Error()
|
||||||
elif arg == '-l' or arg == '--list_bots':
|
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 (
|
print (
|
||||||
"""
|
"""
|
||||||
submit_try: Available builders:\n %s
|
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-
|
Can also use the following aliases to run on groups of builders-
|
||||||
%s: Will run against all trybots.
|
%s: Will run against all trybots.
|
||||||
%s: Will run against all compile 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: 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))
|
""" % tuple(format_args))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -208,7 +217,7 @@ Can also use the following aliases to run on groups of builders-
|
||||||
elif bot == COMPILE_BUILDERS:
|
elif bot == COMPILE_BUILDERS:
|
||||||
using_bots = [t for t in trybots if t.startswith('Build')]
|
using_bots = [t for t in trybots if t.startswith('Build')]
|
||||||
elif bot == CQ_BUILDERS:
|
elif bot == CQ_BUILDERS:
|
||||||
using_bots = RetrieveTrybotList(json_filename='cqtrybots')
|
using_bots = cq_trybots
|
||||||
elif bot == REGEX:
|
elif bot == REGEX:
|
||||||
while True:
|
while True:
|
||||||
regex = raw_input("Enter your trybot regex: ")
|
regex = raw_input("Enter your trybot regex: ")
|
||||||
|
@ -303,13 +312,14 @@ def SubmitTryRequest(args, is_svn=True):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Retrieve the list of active try builders from the build master.
|
# 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.
|
# Determine if we're in an SVN checkout.
|
||||||
is_svn = os.path.isdir('.svn')
|
is_svn = os.path.isdir('.svn')
|
||||||
|
|
||||||
# Parse and validate the command-line arguments.
|
# 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.
|
# Submit the try request.
|
||||||
SubmitTryRequest(args, is_svn=is_svn)
|
SubmitTryRequest(args, is_svn=is_svn)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче