Reviewers: jarin,
Message:
PTAL
Description:
Automatically determine current V8 sheriff in chromium-roll script.
BUG=
Please review this at https://codereview.chromium.org/225283007/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+82, -13 lines):
M tools/push-to-trunk/auto_roll.py
M tools/push-to-trunk/chromium_roll.py
M tools/push-to-trunk/common_includes.py
M tools/push-to-trunk/test_scripts.py
Index: tools/push-to-trunk/auto_roll.py
diff --git a/tools/push-to-trunk/auto_roll.py
b/tools/push-to-trunk/auto_roll.py
index
567f23b0fe8a59df321dc1d62d71b4bf31eb296a..607ca0897abf7db55951f117279f90a1ef03dcc1
100755
--- a/tools/push-to-trunk/auto_roll.py
+++ b/tools/push-to-trunk/auto_roll.py
@@ -70,18 +70,23 @@ class RollChromium(Step):
def RunStep(self):
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
self._side_effect_handler.Call(
R(chromium_roll.CONFIG, self._side_effect_handler).Run,
- ["--author", self._options.author,
- "--reviewer", self._options.reviewer,
- "--chromium", self._options.chromium,
- "--force"])
+ args)
class AutoRoll(ScriptsBase):
def _PrepareOptions(self, parser):
- group = parser.add_mutually_exclusive_group()
parser.add_argument("-c", "--chromium", required=True,
help=("The path to your Chromium src/ "
"directory to automate the V8 roll."))
Index: tools/push-to-trunk/chromium_roll.py
diff --git a/tools/push-to-trunk/chromium_roll.py
b/tools/push-to-trunk/chromium_roll.py
index
adae11d0498e05ed1dee13ff03026288a9daf71c..35ab24b05d6ad492a6aed7399c3ff009e7f128ee
100755
--- a/tools/push-to-trunk/chromium_roll.py
+++ b/tools/push-to-trunk/chromium_roll.py
@@ -90,7 +90,7 @@ class UploadCL(Step):
deps)
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
rev = self._options.reviewer
else:
@@ -99,7 +99,11 @@ class UploadCL(Step):
rev = self.ReadLine()
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,
force=self._options.force_upload)
print "CL uploaded."
@@ -159,6 +163,7 @@ class ChromiumRoll(ScriptsBase):
Preparation,
DetectLastPush,
CheckChromium,
+ DetermineV8Sheriff,
SwitchChromium,
UpdateChromiumCheckout,
UploadCL,
Index: tools/push-to-trunk/common_includes.py
diff --git a/tools/push-to-trunk/common_includes.py
b/tools/push-to-trunk/common_includes.py
index
efea54a0998a71986a1be5c334fbcafde20820e8..44a6691741d9156592a1962e9d6e6ca0a18ef184
100644
--- a/tools/push-to-trunk/common_includes.py
+++ b/tools/push-to-trunk/common_includes.py
@@ -28,6 +28,7 @@
import argparse
import datetime
+import imp
import json
import os
import re
@@ -467,6 +468,40 @@ class UploadStep(Step):
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,
options=None,
side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER):
# Allow to pass in empty dictionaries.
@@ -511,11 +546,17 @@ class ScriptsBase(object):
parser = argparse.ArgumentParser(description=self._Description())
parser.add_argument("-a", "--author", default="",
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="",
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",
- help="Specify the step where to start work. Default:
0.",
- default=0, type=int)
+ help="Specify the step where to start work. Default: 0.",
+ default=0, type=int)
self._PrepareOptions(parser)
@@ -529,6 +570,10 @@ class ScriptsBase(object):
print "Bad step number %d" % options.step
parser.print_help()
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.
options.manual = getattr(options, "manual", True)
Index: tools/push-to-trunk/test_scripts.py
diff --git a/tools/push-to-trunk/test_scripts.py
b/tools/push-to-trunk/test_scripts.py
index
bd19253b269a03cd2e2738283d363e1119696634..2df45300197a4c7b120123fbb2db983ded565fc3
100644
--- a/tools/push-to-trunk/test_scripts.py
+++ b/tools/push-to-trunk/test_scripts.py
@@ -769,8 +769,15 @@ Performance and stability improvements on all
platforms.""", commit)
def testPushToTrunkForced(self):
self._PushToTrunk(force=True)
-
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 {"[email protected]": "[email protected]"}
+def get_list():
+ pass""")
+
TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
if not os.path.exists(TEST_CONFIG[CHROMIUM]):
os.makedirs(TEST_CONFIG[CHROMIUM])
@@ -795,23 +802,30 @@ Performance and stability improvements on all
platforms.""", commit)
Git("checkout -b v8-roll-123455", ""),
Git(("commit -am \"Update V8 to version 3.22.5 "
"(based on bleeding_edge revision r123454).\n\n"
- "[email protected]\""),
+ "Please reply to the V8 sheriff [email protected] in "
+ "case of problems.\n\[email protected]\""),
""),
Git(("cl upload --send-mail --email \"[email protected]\"%s"
% 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:
if manual:
self.ExpectReadline([
- RL("[email protected]"), # Chromium reviewer.
+ RL("[email protected]"), # Chromium reviewer.
])
# Expected keyboard input in semi-automatic mode and forced mode:
if not manual:
self.ExpectReadline([])
- args = ["-a", "[email protected]", "-c", TEST_CONFIG[CHROMIUM]]
+ args = ["-a", "[email protected]", "-c", TEST_CONFIG[CHROMIUM],
+ "--sheriff", "--googlers-mapping", googlers_mapping_py]
if force: args.append("-f")
if manual: args.append("-m")
else: args += ["-r", "[email protected]"]
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.