2014-04-02 06:59:25 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from common_includes import *
|
2015-11-24 08:38:54 +00:00
|
|
|
|
|
|
|
ROLL_SUMMARY = ("Summary of changes available at:\n"
|
|
|
|
"https://chromium.googlesource.com/v8/v8/+log/%s..%s")
|
|
|
|
|
|
|
|
ISSUE_MSG = (
|
|
|
|
"""Please follow these instructions for assigning/CC'ing issues:
|
2015-11-30 13:55:03 +00:00
|
|
|
https://github.com/v8/v8/wiki/Triaging%20issues
|
2015-11-24 08:38:54 +00:00
|
|
|
|
|
|
|
Please close rolling in case of a roll revert:
|
|
|
|
https://v8-roll.appspot.com/
|
2016-04-29 09:11:50 +00:00
|
|
|
This only works with a Google account.
|
|
|
|
|
2016-11-18 05:59:17 +00:00
|
|
|
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel""")
|
2015-11-24 08:38:54 +00:00
|
|
|
|
|
|
|
class Preparation(Step):
|
|
|
|
MESSAGE = "Preparation."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2015-11-24 11:00:05 +00:00
|
|
|
self['json_output']['monitoring_state'] = 'preparation'
|
2015-11-24 08:38:54 +00:00
|
|
|
# Update v8 remote tracking branches.
|
|
|
|
self.GitFetchOrigin()
|
|
|
|
self.Git("fetch origin +refs/tags/*:refs/tags/*")
|
2014-04-02 06:59:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DetectLastRoll(Step):
|
|
|
|
MESSAGE = "Detect commit ID of the last Chromium roll."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2015-11-24 11:00:05 +00:00
|
|
|
self['json_output']['monitoring_state'] = 'detect_last_roll'
|
2015-11-24 08:38:54 +00:00
|
|
|
self["last_roll"] = self._options.last_roll
|
|
|
|
if not self["last_roll"]:
|
|
|
|
# Interpret the DEPS file to retrieve the v8 revision.
|
|
|
|
# TODO(machenbach): This should be part or the roll-deps api of
|
|
|
|
# depot_tools.
|
|
|
|
Var = lambda var: '%s'
|
|
|
|
exec(FileToText(os.path.join(self._options.chromium, "DEPS")))
|
|
|
|
|
|
|
|
# The revision rolled last.
|
|
|
|
self["last_roll"] = vars['v8_revision']
|
|
|
|
self["last_version"] = self.GetVersionTag(self["last_roll"])
|
|
|
|
assert self["last_version"], "The last rolled v8 revision is not tagged."
|
|
|
|
|
|
|
|
|
|
|
|
class DetectRevisionToRoll(Step):
|
|
|
|
MESSAGE = "Detect commit ID of the V8 revision to roll."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2015-11-24 11:00:05 +00:00
|
|
|
self['json_output']['monitoring_state'] = 'detect_revision'
|
2015-11-24 08:38:54 +00:00
|
|
|
self["roll"] = self._options.revision
|
|
|
|
if self["roll"]:
|
|
|
|
# If the revision was passed on the cmd line, continue script execution
|
|
|
|
# in the next step.
|
|
|
|
return False
|
|
|
|
|
2015-03-05 10:50:00 +00:00
|
|
|
# The revision that should be rolled. Check for the latest of the most
|
|
|
|
# recent releases based on commit timestamp.
|
|
|
|
revisions = self.GetRecentReleases(
|
|
|
|
max_age=self._options.max_age * DAY_IN_SECONDS)
|
|
|
|
assert revisions, "Didn't find any recent release."
|
2015-01-28 10:08:53 +00:00
|
|
|
|
2015-03-05 10:50:00 +00:00
|
|
|
# There must be some progress between the last roll and the new candidate
|
|
|
|
# revision (i.e. we don't go backwards). The revisions are ordered newest
|
|
|
|
# to oldest. It is possible that the newest timestamp has no progress
|
|
|
|
# compared to the last roll, i.e. if the newest release is a cherry-pick
|
|
|
|
# on a release branch. Then we look further.
|
|
|
|
for revision in revisions:
|
2015-03-05 14:04:59 +00:00
|
|
|
version = self.GetVersionTag(revision)
|
|
|
|
assert version, "Internal error. All recent releases should have a tag"
|
|
|
|
|
2015-11-24 08:38:54 +00:00
|
|
|
if SortingKey(self["last_version"]) < SortingKey(version):
|
2015-03-05 10:50:00 +00:00
|
|
|
self["roll"] = revision
|
|
|
|
break
|
|
|
|
else:
|
2014-04-02 06:59:25 +00:00
|
|
|
print("There is no newer v8 revision than the one in Chromium (%s)."
|
2015-02-16 12:21:34 +00:00
|
|
|
% self["last_roll"])
|
2015-11-24 11:00:05 +00:00
|
|
|
self['json_output']['monitoring_state'] = 'up_to_date'
|
2014-04-02 06:59:25 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
|
2015-11-24 08:38:54 +00:00
|
|
|
class PrepareRollCandidate(Step):
|
|
|
|
MESSAGE = "Robustness checks of the roll candidate."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2015-11-24 11:00:05 +00:00
|
|
|
self['json_output']['monitoring_state'] = 'prepare_candidate'
|
2015-11-24 08:38:54 +00:00
|
|
|
self["roll_title"] = self.GitLog(n=1, format="%s",
|
|
|
|
git_hash=self["roll"])
|
|
|
|
|
|
|
|
# Make sure the last roll and the roll candidate are releases.
|
|
|
|
version = self.GetVersionTag(self["roll"])
|
|
|
|
assert version, "The revision to roll is not tagged."
|
|
|
|
version = self.GetVersionTag(self["last_roll"])
|
|
|
|
assert version, "The revision used as last roll is not tagged."
|
|
|
|
|
|
|
|
|
|
|
|
class SwitchChromium(Step):
|
|
|
|
MESSAGE = "Switch to Chromium checkout."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2015-11-24 11:00:05 +00:00
|
|
|
self['json_output']['monitoring_state'] = 'switch_chromium'
|
2015-11-24 08:38:54 +00:00
|
|
|
cwd = self._options.chromium
|
|
|
|
self.InitialEnvironmentChecks(cwd)
|
|
|
|
# Check for a clean workdir.
|
|
|
|
if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover
|
|
|
|
self.Die("Workspace is not clean. Please commit or undo your changes.")
|
|
|
|
# Assert that the DEPS file is there.
|
|
|
|
if not os.path.exists(os.path.join(cwd, "DEPS")): # pragma: no cover
|
|
|
|
self.Die("DEPS file not present.")
|
|
|
|
|
|
|
|
|
|
|
|
class UpdateChromiumCheckout(Step):
|
|
|
|
MESSAGE = "Update the checkout and create a new branch."
|
2014-04-02 06:59:25 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2015-11-24 11:00:05 +00:00
|
|
|
self['json_output']['monitoring_state'] = 'update_chromium'
|
2015-11-24 08:38:54 +00:00
|
|
|
cwd = self._options.chromium
|
|
|
|
self.GitCheckout("master", cwd=cwd)
|
|
|
|
self.DeleteBranch("work-branch", cwd=cwd)
|
|
|
|
self.GitPull(cwd=cwd)
|
|
|
|
|
|
|
|
# Update v8 remotes.
|
|
|
|
self.GitFetchOrigin()
|
|
|
|
|
|
|
|
self.GitCreateBranch("work-branch", cwd=cwd)
|
|
|
|
|
|
|
|
|
|
|
|
class UploadCL(Step):
|
|
|
|
MESSAGE = "Create and upload CL."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2015-11-24 11:00:05 +00:00
|
|
|
self['json_output']['monitoring_state'] = 'upload'
|
2015-11-24 08:38:54 +00:00
|
|
|
cwd = self._options.chromium
|
|
|
|
# Patch DEPS file.
|
|
|
|
if self.Command("roll-dep-svn", "v8 %s" %
|
|
|
|
self["roll"], cwd=cwd) is None:
|
|
|
|
self.Die("Failed to create deps for %s" % self["roll"])
|
|
|
|
|
|
|
|
message = []
|
|
|
|
message.append("Update V8 to %s." % self["roll_title"].lower())
|
|
|
|
|
|
|
|
message.append(
|
|
|
|
ROLL_SUMMARY % (self["last_roll"][:8], self["roll"][:8]))
|
|
|
|
|
|
|
|
message.append(ISSUE_MSG)
|
|
|
|
|
|
|
|
message.append("TBR=%s" % self._options.reviewer)
|
|
|
|
self.GitCommit("\n\n".join(message), author=self._options.author, cwd=cwd)
|
|
|
|
if not self._options.dry_run:
|
|
|
|
self.GitUpload(author=self._options.author,
|
|
|
|
force=True,
|
2016-03-29 13:13:22 +00:00
|
|
|
bypass_hooks=True,
|
2015-11-24 08:38:54 +00:00
|
|
|
cq=self._options.use_commit_queue,
|
|
|
|
cwd=cwd)
|
|
|
|
print "CL uploaded."
|
|
|
|
else:
|
|
|
|
print "Dry run - don't upload."
|
|
|
|
|
|
|
|
self.GitCheckout("master", cwd=cwd)
|
|
|
|
self.GitDeleteBranch("work-branch", cwd=cwd)
|
|
|
|
|
|
|
|
class CleanUp(Step):
|
|
|
|
MESSAGE = "Done!"
|
|
|
|
|
|
|
|
def RunStep(self):
|
2015-11-24 11:00:05 +00:00
|
|
|
self['json_output']['monitoring_state'] = 'success'
|
2015-11-24 08:38:54 +00:00
|
|
|
print("Congratulations, you have successfully rolled %s into "
|
|
|
|
"Chromium."
|
|
|
|
% self["roll"])
|
|
|
|
|
|
|
|
# Clean up all temporary files.
|
|
|
|
Command("rm", "-f %s*" % self._config["PERSISTFILE_BASENAME"])
|
2014-04-02 06:59:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AutoRoll(ScriptsBase):
|
|
|
|
def _PrepareOptions(self, parser):
|
|
|
|
parser.add_argument("-c", "--chromium", required=True,
|
|
|
|
help=("The path to your Chromium src/ "
|
|
|
|
"directory to automate the V8 roll."))
|
2015-11-24 08:38:54 +00:00
|
|
|
parser.add_argument("--last-roll",
|
|
|
|
help="The git commit ID of the last rolled version. "
|
|
|
|
"Auto-detected if not specified.")
|
2016-01-04 12:03:39 +00:00
|
|
|
parser.add_argument("--max-age", default=7, type=int,
|
2015-03-05 10:50:00 +00:00
|
|
|
help="Maximum age in days of the latest release.")
|
2015-11-24 08:38:54 +00:00
|
|
|
parser.add_argument("--revision",
|
|
|
|
help="Revision to roll. Auto-detected if not "
|
|
|
|
"specified."),
|
|
|
|
parser.add_argument("--roll", help="Deprecated.",
|
|
|
|
default=True, action="store_true")
|
|
|
|
parser.add_argument("--use-commit-queue",
|
|
|
|
help="Check the CQ bit on upload.",
|
|
|
|
default=True, action="store_true")
|
2014-04-02 06:59:25 +00:00
|
|
|
|
|
|
|
def _ProcessOptions(self, options): # pragma: no cover
|
2015-11-24 08:38:54 +00:00
|
|
|
if not options.author or not options.reviewer:
|
|
|
|
print "A reviewer (-r) and an author (-a) are required."
|
2014-04-02 06:59:25 +00:00
|
|
|
return False
|
2015-11-24 08:38:54 +00:00
|
|
|
|
|
|
|
options.requires_editor = False
|
|
|
|
options.force = True
|
|
|
|
options.manual = False
|
2014-04-02 06:59:25 +00:00
|
|
|
return True
|
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
def _Config(self):
|
|
|
|
return {
|
2015-11-24 08:38:54 +00:00
|
|
|
"PERSISTFILE_BASENAME": "/tmp/v8-chromium-roll-tempfile",
|
2014-09-23 14:41:36 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 06:59:25 +00:00
|
|
|
def _Steps(self):
|
|
|
|
return [
|
2015-11-24 08:38:54 +00:00
|
|
|
Preparation,
|
2014-04-02 06:59:25 +00:00
|
|
|
DetectLastRoll,
|
2015-11-24 08:38:54 +00:00
|
|
|
DetectRevisionToRoll,
|
|
|
|
PrepareRollCandidate,
|
|
|
|
SwitchChromium,
|
|
|
|
UpdateChromiumCheckout,
|
|
|
|
UploadCL,
|
|
|
|
CleanUp,
|
2014-04-02 06:59:25 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": # pragma: no cover
|
2014-09-23 14:41:36 +00:00
|
|
|
sys.exit(AutoRoll().Run())
|