Revision: 20576
Author:   [email protected]
Date:     Tue Apr  8 12:07:49 2014 UTC
Log: Automatically determine current V8 sheriff in chromium-roll script.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/225283007
http://code.google.com/p/v8/source/detail?r=20576

Modified:
 /branches/bleeding_edge/tools/push-to-trunk/auto_roll.py
 /branches/bleeding_edge/tools/push-to-trunk/chromium_roll.py
 /branches/bleeding_edge/tools/push-to-trunk/common_includes.py
 /branches/bleeding_edge/tools/push-to-trunk/test_scripts.py

=======================================
--- /branches/bleeding_edge/tools/push-to-trunk/auto_roll.py Fri Apr 4 07:23:45 2014 UTC +++ /branches/bleeding_edge/tools/push-to-trunk/auto_roll.py Tue Apr 8 12:07:49 2014 UTC
@@ -70,18 +70,23 @@

   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."))
=======================================
--- /branches/bleeding_edge/tools/push-to-trunk/chromium_roll.py Fri Apr 4 07:23:45 2014 UTC +++ /branches/bleeding_edge/tools/push-to-trunk/chromium_roll.py Tue Apr 8 12:07:49 2014 UTC
@@ -90,7 +90,7 @@
                   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 @@
       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 @@
       Preparation,
       DetectLastPush,
       CheckChromium,
+      DetermineV8Sheriff,
       SwitchChromium,
       UpdateChromiumCheckout,
       UploadCL,
=======================================
--- /branches/bleeding_edge/tools/push-to-trunk/common_includes.py Fri Apr 4 07:23:45 2014 UTC +++ /branches/bleeding_edge/tools/push-to-trunk/common_includes.py Tue Apr 8 12:07:49 2014 UTC
@@ -28,6 +28,7 @@

 import argparse
 import datetime
+import imp
 import json
 import os
 import re
@@ -467,6 +468,40 @@
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 @@
     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 @@
       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)
=======================================
--- /branches/bleeding_edge/tools/push-to-trunk/test_scripts.py Fri Apr 4 07:23:45 2014 UTC +++ /branches/bleeding_edge/tools/push-to-trunk/test_scripts.py Tue Apr 8 12:07:49 2014 UTC
@@ -769,8 +769,15 @@
   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""")

-  def _ChromiumRoll(self, force=False, manual=False):
     TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
     if not os.path.exists(TEST_CONFIG[CHROMIUM]):
       os.makedirs(TEST_CONFIG[CHROMIUM])
@@ -795,23 +802,30 @@
       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.

Reply via email to