Let auto-roll push the lkgr.

BUG=
R=jkummerow@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20168 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2aaaeb78
...@@ -44,6 +44,8 @@ CONFIG = { ...@@ -44,6 +44,8 @@ CONFIG = {
SETTINGS_LOCATION: "~/.auto-roll", SETTINGS_LOCATION: "~/.auto-roll",
} }
PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
class Preparation(Step): class Preparation(Step):
MESSAGE = "Preparation." MESSAGE = "Preparation."
...@@ -77,42 +79,40 @@ class CheckTreeStatus(Step): ...@@ -77,42 +79,40 @@ class CheckTreeStatus(Step):
% self["tree_message"]) % self["tree_message"])
class FetchLatestRevision(Step): class FetchLKGR(Step):
MESSAGE = "Fetching latest V8 revision." MESSAGE = "Fetching V8 LKGR."
def RunStep(self): def RunStep(self):
match = re.match(r"^r(\d+) ", self.GitSVNLog()) lkgr_url = "https://v8-status.appspot.com/lkgr"
if not match: # pragma: no cover # Retry several times since app engine might have issues.
self.Die("Could not extract current svn revision from log.") self["lkgr"] = self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300])
self["latest"] = match.group(1)
class CheckLastPush(Step): class CheckLastPush(Step):
MESSAGE = "Checking last V8 push to trunk." MESSAGE = "Checking last V8 push to trunk."
def RunStep(self): def RunStep(self):
last_push_hash = self.FindLastTrunkPush() last_push = self.FindLastTrunkPush()
last_push = int(self.GitSVNFindSVNRev(last_push_hash))
# Retrieve the bleeding edge revision of the last push from the text in
# the push commit message.
last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
last_push_be = PUSH_MESSAGE_RE.match(last_push_title).group(1)
if not last_push_be: # pragma: no cover
self.Die("Could not retrieve bleeding edge revision for trunk push %s"
% last_push)
# TODO(machenbach): This metric counts all revisions. It could be # TODO(machenbach): This metric counts all revisions. It could be
# improved by counting only the revisions on bleeding_edge. # improved by counting only the revisions on bleeding_edge.
if int(self["latest"]) - last_push < 10: # pragma: no cover if int(self["lkgr"]) - int(last_push_be) < 10: # pragma: no cover
# This makes sure the script doesn't push twice in a row when the cron # This makes sure the script doesn't push twice in a row when the cron
# job retries several times. # job retries several times.
self.Die("Last push too recently: %d" % last_push) self.Die("Last push too recently: %s" % last_push_be)
class FetchLKGR(Step):
MESSAGE = "Fetching V8 LKGR."
def RunStep(self):
lkgr_url = "https://v8-status.appspot.com/lkgr"
# Retry several times since app engine might have issues.
self["lkgr"] = self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300])
class PushToTrunk(Step): class PushToTrunk(Step):
MESSAGE = "Pushing to trunk if possible." MESSAGE = "Pushing to trunk if specified."
def PushTreeStatus(self, message): def PushTreeStatus(self, message):
if not self._options.status_password: if not self._options.status_password:
...@@ -129,26 +129,21 @@ class PushToTrunk(Step): ...@@ -129,26 +129,21 @@ class PushToTrunk(Step):
wait_plan=[5, 20]) wait_plan=[5, 20])
def RunStep(self): def RunStep(self):
latest = int(self["latest"]) print "Pushing lkgr %s to trunk." % self["lkgr"]
lkgr = int(self["lkgr"]) self.PushTreeStatus("Tree is closed (preparing to push)")
if latest == lkgr:
print "ToT (r%d) is clean. Pushing to trunk." % latest # TODO(machenbach): Update the script before calling it.
self.PushTreeStatus("Tree is closed (preparing to push)") try:
if self._options.push:
# TODO(machenbach): Update the script before calling it. P = push_to_trunk.PushToTrunk
try: self._side_effect_handler.Call(
if self._options.push: P(push_to_trunk.CONFIG, self._side_effect_handler).Run,
P = push_to_trunk.PushToTrunk ["-author", self._options.author,
self._side_effect_handler.Call( "-reviewer", self._options.reviewer,
P(push_to_trunk.CONFIG, self._side_effect_handler).Run, "-revision", self["lkgr"],
["-a", self._options.author, "-force"])
"-r", self._options.reviewer, finally:
"-f"]) self.PushTreeStatus(self["tree_message"])
finally:
self.PushTreeStatus(self["tree_message"])
else:
print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk."
% (latest, lkgr))
class AutoRoll(ScriptsBase): class AutoRoll(ScriptsBase):
...@@ -173,9 +168,8 @@ class AutoRoll(ScriptsBase): ...@@ -173,9 +168,8 @@ class AutoRoll(ScriptsBase):
Preparation, Preparation,
CheckAutoRollSettings, CheckAutoRollSettings,
CheckTreeStatus, CheckTreeStatus,
FetchLatestRevision,
CheckLastPush,
FetchLKGR, FetchLKGR,
CheckLastPush,
PushToTrunk, PushToTrunk,
] ]
......
...@@ -33,7 +33,6 @@ import unittest ...@@ -33,7 +33,6 @@ import unittest
import auto_roll import auto_roll
from auto_roll import CheckLastPush from auto_roll import CheckLastPush
from auto_roll import FetchLatestRevision
from auto_roll import SETTINGS_LOCATION from auto_roll import SETTINGS_LOCATION
import common_includes import common_includes
from common_includes import * from common_includes import *
...@@ -832,11 +831,15 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -832,11 +831,15 @@ Performance and stability improvements on all platforms.""", commit)
def testCheckLastPushRecently(self): def testCheckLastPushRecently(self):
self.ExpectGit([ self.ExpectGit([
Git("svn log -1 --oneline", "r101 | Text"), Git(("log -1 --format=%H --grep="
Git("svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."), "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
"svn/trunk"), "hash2\n"),
Git("log -1 --format=%s hash2",
"Version 3.4.5 (based on bleeding_edge revision r99)\n"),
]) ])
self.RunStep(auto_roll.AutoRoll, FetchLatestRevision, AUTO_ROLL_ARGS) self._state["lkgr"] = "101"
self.assertRaises(Exception, lambda: self.RunStep(auto_roll.AutoRoll, self.assertRaises(Exception, lambda: self.RunStep(auto_roll.AutoRoll,
CheckLastPush, CheckLastPush,
AUTO_ROLL_ARGS)) AUTO_ROLL_ARGS))
...@@ -864,11 +867,11 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -864,11 +867,11 @@ Performance and stability improvements on all platforms.""", commit)
Git("status -s -uno", ""), Git("status -s -uno", ""),
Git("status -s -b -uno", "## some_branch\n"), Git("status -s -b -uno", "## some_branch\n"),
Git("svn fetch", ""), Git("svn fetch", ""),
Git("svn log -1 --oneline", "r100 | Text"),
Git(("log -1 --format=%H --grep=\"" Git(("log -1 --format=%H --grep=\""
"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\""
" svn/trunk"), "push_hash\n"), " svn/trunk"), "push_hash\n"),
Git("svn find-rev push_hash", "65"), Git("log -1 --format=%s push_hash",
"Version 3.4.5 (based on bleeding_edge revision r79)\n"),
]) ])
auto_roll.AutoRoll(TEST_CONFIG, self).Run( auto_roll.AutoRoll(TEST_CONFIG, self).Run(
...@@ -878,7 +881,6 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -878,7 +881,6 @@ Performance and stability improvements on all platforms.""", commit)
% TEST_CONFIG[PERSISTFILE_BASENAME])) % TEST_CONFIG[PERSISTFILE_BASENAME]))
self.assertEquals("100", state["lkgr"]) self.assertEquals("100", state["lkgr"])
self.assertEquals("100", state["latest"])
def testAutoRollStoppedBySettings(self): def testAutoRollStoppedBySettings(self):
TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
......
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