Add better remote control to push-to-trunk auto-roll script.

This CL enables controlling the automatic push-to-trunk via a settings file .auto-roll in the home directory or via the v8 status app message.

Pushes can be disabled by setting .auto-roll to {"enable_auto_roll": false} or by adding the phrase "nopush" or "no push" to http://v8-status.appspot.com/.

R=ulan@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18472 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
machenbach@chromium.org 2014-01-07 15:23:48 +00:00
parent 286957b474
commit 0030356cd0
3 changed files with 72 additions and 3 deletions

View File

@ -26,15 +26,20 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import json
import optparse
import os
import re
import sys
from common_includes import *
SETTINGS_LOCATION = "SETTINGS_LOCATION"
CONFIG = {
PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile",
DOT_GIT_LOCATION: ".git",
SETTINGS_LOCATION: "~/.auto-roll",
}
@ -52,6 +57,29 @@ class Preparation(Step):
self.CommonPrepare()
class CheckAutoRollSettings(Step):
MESSAGE = "Checking settings file."
def RunStep(self):
settings_file = os.path.realpath(self.Config(SETTINGS_LOCATION))
if os.path.exists(settings_file):
settings_dict = json.loads(FileToText(settings_file))
if settings_dict.get("enable_auto_roll") is False:
self.Die("Push to trunk disabled by auto-roll settings file: %s"
% settings_file)
class CheckTreeStatus(Step):
MESSAGE = "Checking v8 tree status message."
def RunStep(self):
status_url = "https://v8-status.appspot.com/current?format=json"
status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300])
message = json.loads(status_json)["message"]
if re.search(r"nopush|no push", message, flags=re.I):
self.Die("Push to trunk disabled by tree state: %s" % message)
class FetchLatestRevision(Step):
MESSAGE = "Fetching latest V8 revision."
@ -115,6 +143,8 @@ def RunAutoRoll(config,
side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER):
step_classes = [
Preparation,
CheckAutoRollSettings,
CheckTreeStatus,
FetchLatestRevision,
CheckLastPush,
FetchLKGR,

View File

@ -215,6 +215,7 @@ DEFAULT_SIDE_EFFECT_HANDLER = SideEffectHandler()
class NoRetryException(Exception):
pass
class CommonOptions(object):
def __init__(self, options, manual=True):
self.requires_editor = True

View File

@ -38,6 +38,7 @@ import auto_roll
from auto_roll import AutoRollOptions
from auto_roll import CheckLastPush
from auto_roll import FetchLatestRevision
from auto_roll import SETTINGS_LOCATION
TEST_CONFIG = {
@ -53,6 +54,7 @@ TEST_CONFIG = {
COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg",
CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium",
DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS",
SETTINGS_LOCATION: None,
}
@ -746,8 +748,11 @@ Performance and stability improvements on all platforms."""
def testAutoRoll(self):
TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
self.ExpectReadURL([
["https://v8-status.appspot.com/current?format=json",
"{\"message\": \"Tree is throttled\"}"],
["https://v8-status.appspot.com/lkgr", Exception("Network problem")],
["https://v8-status.appspot.com/lkgr", "100"],
])
@ -760,13 +765,46 @@ Performance and stability improvements on all platforms."""
["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."],
])
auto_roll.RunAutoRoll(TEST_CONFIG,
AutoRollOptions(MakeOptions(m=False, f=True)),
self)
auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self)
self.assertEquals("100", self.MakeStep().Restore("lkgr"))
self.assertEquals("101", self.MakeStep().Restore("latest"))
def testAutoRollStoppedBySettings(self):
TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile()
TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION])
self.ExpectReadURL([])
self.ExpectGit([
["status -s -uno", ""],
["status -s -b -uno", "## some_branch\n"],
["svn fetch", ""],
])
def RunAutoRoll():
auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self)
self.assertRaises(Exception, RunAutoRoll)
def testAutoRollStoppedByTreeStatus(self):
TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
self.ExpectReadURL([
["https://v8-status.appspot.com/current?format=json",
"{\"message\": \"Tree is throttled (no push)\"}"],
])
self.ExpectGit([
["status -s -uno", ""],
["status -s -b -uno", "## some_branch\n"],
["svn fetch", ""],
])
def RunAutoRoll():
auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self)
self.assertRaises(Exception, RunAutoRoll)
class SystemTest(unittest.TestCase):
def testReload(self):