Automatically determine current V8 sheriff in chromium-roll script.

BUG=
R=jarin@chromium.org

Review URL: https://codereview.chromium.org/225283007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20576 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 91dec1ad
...@@ -70,18 +70,23 @@ class RollChromium(Step): ...@@ -70,18 +70,23 @@ class RollChromium(Step):
def RunStep(self): def RunStep(self):
if self._options.roll: if self._options.roll:
args = [
"--author", self._options.author,
"--reviewer", self._options.reviewer,
"--chromium", self._options.chromium,
"--force",
]
if self._options.sheriff:
args.extend([
"--sheriff", "--googlers-mapping", self._options.googlers_mapping])
R = chromium_roll.ChromiumRoll R = chromium_roll.ChromiumRoll
self._side_effect_handler.Call( self._side_effect_handler.Call(
R(chromium_roll.CONFIG, self._side_effect_handler).Run, R(chromium_roll.CONFIG, self._side_effect_handler).Run,
["--author", self._options.author, args)
"--reviewer", self._options.reviewer,
"--chromium", self._options.chromium,
"--force"])
class AutoRoll(ScriptsBase): class AutoRoll(ScriptsBase):
def _PrepareOptions(self, parser): def _PrepareOptions(self, parser):
group = parser.add_mutually_exclusive_group()
parser.add_argument("-c", "--chromium", required=True, parser.add_argument("-c", "--chromium", required=True,
help=("The path to your Chromium src/ " help=("The path to your Chromium src/ "
"directory to automate the V8 roll.")) "directory to automate the V8 roll."))
......
...@@ -90,7 +90,7 @@ class UploadCL(Step): ...@@ -90,7 +90,7 @@ class UploadCL(Step):
deps) deps)
TextToFile(deps, self.Config(DEPS_FILE)) TextToFile(deps, self.Config(DEPS_FILE))
if self._options.reviewer: if self._options.reviewer and not self._options.manual:
print "Using account %s for review." % self._options.reviewer print "Using account %s for review." % self._options.reviewer
rev = self._options.reviewer rev = self._options.reviewer
else: else:
...@@ -99,7 +99,11 @@ class UploadCL(Step): ...@@ -99,7 +99,11 @@ class UploadCL(Step):
rev = self.ReadLine() rev = self.ReadLine()
commit_title = "Update V8 to %s." % self["push_title"].lower() commit_title = "Update V8 to %s." % self["push_title"].lower()
self.GitCommit("%s\n\nTBR=%s" % (commit_title, rev)) sheriff = ""
if self["sheriff"]:
sheriff = ("\n\nPlease reply to the V8 sheriff %s in case of problems."
% self["sheriff"])
self.GitCommit("%s%s\n\nTBR=%s" % (commit_title, sheriff, rev))
self.GitUpload(author=self._options.author, self.GitUpload(author=self._options.author,
force=self._options.force_upload) force=self._options.force_upload)
print "CL uploaded." print "CL uploaded."
...@@ -159,6 +163,7 @@ class ChromiumRoll(ScriptsBase): ...@@ -159,6 +163,7 @@ class ChromiumRoll(ScriptsBase):
Preparation, Preparation,
DetectLastPush, DetectLastPush,
CheckChromium, CheckChromium,
DetermineV8Sheriff,
SwitchChromium, SwitchChromium,
UpdateChromiumCheckout, UpdateChromiumCheckout,
UploadCL, UploadCL,
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
import argparse import argparse
import datetime import datetime
import imp
import json import json
import os import os
import re import re
...@@ -467,6 +468,40 @@ class UploadStep(Step): ...@@ -467,6 +468,40 @@ class UploadStep(Step):
self.GitUpload(reviewer, self._options.author, self._options.force_upload) self.GitUpload(reviewer, self._options.author, self._options.force_upload)
class DetermineV8Sheriff(Step):
MESSAGE = "Determine the V8 sheriff for code review."
def RunStep(self):
self["sheriff"] = None
if not self._options.sheriff: # pragma: no cover
return
try:
# The googlers mapping maps @google.com accounts to @chromium.org
# accounts.
googlers = imp.load_source('googlers_mapping',
self._options.googlers_mapping)
googlers = googlers.list_to_dict(googlers.get_list())
except: # pragma: no cover
print "Skip determining sheriff without googler mapping."
return
# The sheriff determined by the rotation on the waterfall has a
# @google.com account.
url = "https://chromium-build.appspot.com/p/chromium/sheriff_v8.js"
match = re.match(r"document\.write\('(\w+)'\)", self.ReadURL(url))
# If "channel is sheriff", we can't match an account.
if match:
g_name = match.group(1)
self["sheriff"] = googlers.get(g_name + "@google.com",
g_name + "@chromium.org")
self._options.reviewer = self["sheriff"]
print "Found active sheriff: %s" % self["sheriff"]
else:
print "No active sheriff found."
def MakeStep(step_class=Step, number=0, state=None, config=None, def MakeStep(step_class=Step, number=0, state=None, config=None,
options=None, side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): options=None, side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER):
# Allow to pass in empty dictionaries. # Allow to pass in empty dictionaries.
...@@ -511,8 +546,14 @@ class ScriptsBase(object): ...@@ -511,8 +546,14 @@ class ScriptsBase(object):
parser = argparse.ArgumentParser(description=self._Description()) parser = argparse.ArgumentParser(description=self._Description())
parser.add_argument("-a", "--author", default="", parser.add_argument("-a", "--author", default="",
help="The author email used for rietveld.") help="The author email used for rietveld.")
parser.add_argument("-g", "--googlers-mapping",
help="Path to the script mapping google accounts.")
parser.add_argument("-r", "--reviewer", default="", parser.add_argument("-r", "--reviewer", default="",
help="The account name to be used for reviews.") help="The account name to be used for reviews.")
parser.add_argument("--sheriff", default=False, action="store_true",
help=("Determine current sheriff to review CLs. On "
"success, this will overwrite the reviewer "
"option."))
parser.add_argument("-s", "--step", parser.add_argument("-s", "--step",
help="Specify the step where to start work. Default: 0.", help="Specify the step where to start work. Default: 0.",
default=0, type=int) default=0, type=int)
...@@ -529,6 +570,10 @@ class ScriptsBase(object): ...@@ -529,6 +570,10 @@ class ScriptsBase(object):
print "Bad step number %d" % options.step print "Bad step number %d" % options.step
parser.print_help() parser.print_help()
return None return None
if options.sheriff and not options.googlers_mapping: # pragma: no cover
print "To determine the current sheriff, requires the googler mapping"
parser.print_help()
return None
# Defaults for options, common to all scripts. # Defaults for options, common to all scripts.
options.manual = getattr(options, "manual", True) options.manual = getattr(options, "manual", True)
......
...@@ -769,8 +769,15 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -769,8 +769,15 @@ Performance and stability improvements on all platforms.""", commit)
def testPushToTrunkForced(self): def testPushToTrunkForced(self):
self._PushToTrunk(force=True) self._PushToTrunk(force=True)
def _ChromiumRoll(self, force=False, manual=False): def _ChromiumRoll(self, force=False, manual=False):
googlers_mapping_py = "%s-mapping.py" % TEST_CONFIG[PERSISTFILE_BASENAME]
with open(googlers_mapping_py, "w") as f:
f.write("""
def list_to_dict(entries):
return {"g_name@google.com": "c_name@chromium.org"}
def get_list():
pass""")
TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
if not os.path.exists(TEST_CONFIG[CHROMIUM]): if not os.path.exists(TEST_CONFIG[CHROMIUM]):
os.makedirs(TEST_CONFIG[CHROMIUM]) os.makedirs(TEST_CONFIG[CHROMIUM])
...@@ -795,23 +802,30 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -795,23 +802,30 @@ Performance and stability improvements on all platforms.""", commit)
Git("checkout -b v8-roll-123455", ""), Git("checkout -b v8-roll-123455", ""),
Git(("commit -am \"Update V8 to version 3.22.5 " Git(("commit -am \"Update V8 to version 3.22.5 "
"(based on bleeding_edge revision r123454).\n\n" "(based on bleeding_edge revision r123454).\n\n"
"TBR=reviewer@chromium.org\""), "Please reply to the V8 sheriff c_name@chromium.org in "
"case of problems.\n\nTBR=c_name@chromium.org\""),
""), ""),
Git(("cl upload --send-mail --email \"author@chromium.org\"%s" Git(("cl upload --send-mail --email \"author@chromium.org\"%s"
% force_flag), ""), % force_flag), ""),
]) ])
self.ExpectReadURL([
URL("https://chromium-build.appspot.com/p/chromium/sheriff_v8.js",
"document.write('g_name')"),
])
# Expected keyboard input in manual mode: # Expected keyboard input in manual mode:
if manual: if manual:
self.ExpectReadline([ self.ExpectReadline([
RL("reviewer@chromium.org"), # Chromium reviewer. RL("c_name@chromium.org"), # Chromium reviewer.
]) ])
# Expected keyboard input in semi-automatic mode and forced mode: # Expected keyboard input in semi-automatic mode and forced mode:
if not manual: if not manual:
self.ExpectReadline([]) self.ExpectReadline([])
args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]] args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM],
"--sheriff", "--googlers-mapping", googlers_mapping_py]
if force: args.append("-f") if force: args.append("-f")
if manual: args.append("-m") if manual: args.append("-m")
else: args += ["-r", "reviewer@chromium.org"] else: args += ["-r", "reviewer@chromium.org"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment