v8/tools/release/auto_roll.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

239 lines
8.1 KiB
Python
Raw Normal View History

#!/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.
# for py2/py3 compatibility
from __future__ import print_function
import argparse
import os
import sys
from common_includes import *
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:
https://v8.dev/docs/triage-issues
Please close rolling in case of a roll revert:
https://v8-roll.appspot.com/
This only works with a Google account.
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux-blink-rel
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux_optional_gpu_tests_rel
CQ_INCLUDE_TRYBOTS=luci.chromium.try:mac_optional_gpu_tests_rel
CQ_INCLUDE_TRYBOTS=luci.chromium.try:win_optional_gpu_tests_rel
CQ_INCLUDE_TRYBOTS=luci.chromium.try:android_optional_gpu_tests_rel""")
class Preparation(Step):
MESSAGE = "Preparation."
def RunStep(self):
self['json_output']['monitoring_state'] = 'preparation'
# Update v8 remote tracking branches.
self.GitFetchOrigin()
self.Git("fetch origin +refs/tags/*:refs/tags/*")
class DetectLastRoll(Step):
MESSAGE = "Detect commit ID of the last Chromium roll."
def RunStep(self):
self['json_output']['monitoring_state'] = 'detect_last_roll'
self["last_roll"] = self._options.last_roll
if not self["last_roll"]:
Reland "[release] Replace raw DEPS processing with gclient getdep" This reverts commit 29ec319f27d1841f641fc131dc206df61e123142. Reason for revert: Will disable gclient update Original change's description: > Revert "[release] Replace raw DEPS processing with gclient getdep" > > This reverts commit 0ba1c23cd169b8eab526fc74d4ec8cbea7f7a27a. > > Reason for revert: Doesn't work yet > > Original change's description: > > [release] Replace raw DEPS processing with gclient getdep > > > > No-Try: true > > Bug: chromium:1106435 > > Change-Id: I120d3930e4e8be7010d8d1f1928829ca0882638d > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2304578 > > Reviewed-by: Tamer Tas <tmrts@chromium.org> > > Commit-Queue: Michael Achenbach <machenbach@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#68913} > > TBR=machenbach@chromium.org,tmrts@chromium.org,liviurau@chromium.org > > Change-Id: I76e02bfa50fdc5967ab72784cd71114bb82b7261 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: chromium:1106435 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2304585 > Reviewed-by: Michael Achenbach <machenbach@chromium.org> > Commit-Queue: Michael Achenbach <machenbach@chromium.org> > Cr-Commit-Position: refs/heads/master@{#68914} TBR=machenbach@chromium.org,tmrts@chromium.org,liviurau@chromium.org Change-Id: I3d6192a18b7bb14ccdcef6483483b1afe4fbb485 No-Try: true Bug: chromium:1106435 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2304811 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#68923}
2020-07-17 16:35:09 +00:00
# Get last-rolled v8 revision from Chromium's DEPS file.
self["last_roll"] = self.Command(
"gclient", "getdep -r src/v8", cwd=self._options.chromium).strip()
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):
self['json_output']['monitoring_state'] = 'detect_revision'
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
# 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."
# 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:
version = self.GetVersionTag(revision)
assert version, "Internal error. All recent releases should have a tag"
if SortingKey(self["last_version"]) < SortingKey(version):
self["roll"] = revision
break
else:
print("There is no newer v8 revision than the one in Chromium (%s)."
% self["last_roll"])
self['json_output']['monitoring_state'] = 'up_to_date'
return True
class PrepareRollCandidate(Step):
MESSAGE = "Robustness checks of the roll candidate."
def RunStep(self):
self['json_output']['monitoring_state'] = 'prepare_candidate'
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):
self['json_output']['monitoring_state'] = 'switch_chromium'
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."
def RunStep(self):
self['json_output']['monitoring_state'] = 'update_chromium'
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):
self['json_output']['monitoring_state'] = 'upload'
cwd = self._options.chromium
# Patch DEPS file.
Reland "[release] Switch auto-roller to gclient setdep" This reverts commit d169622f83d82eb5f5203d921bc3209b3e2a12b4. Reason for revert: setdep bug should be fixed Original change's description: > Revert "[release] Switch auto-roller to gclient setdep" > > This reverts commit a9f5dd30e4f9cfd2a4c39f8b903b8b6a414691e9. > > Reason for revert: > Temporarily use legacy method until https://crbug.com/843917 is fixed. > > Original change's description: > > [release] Switch auto-roller to gclient setdep > > > > NOTRY=true > > > > Bug: chromium:828745 > > Change-Id: I051f57893937796e01f0b823f1050dd36e0fbfd9 > > Reviewed-on: https://chromium-review.googlesource.com/997556 > > Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org> > > Commit-Queue: Michael Achenbach <machenbach@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#52385} > > TBR=machenbach@chromium.org,hablich@chromium.org,sergiyb@chromium.org > > NOTRY=true > > Bug: chromium:843917 > Change-Id: I69978ba55ffa5996101e1d31bdf10364b7ef273f > Reviewed-on: https://chromium-review.googlesource.com/1064130 > Reviewed-by: Michael Achenbach <machenbach@chromium.org> > Commit-Queue: Michael Achenbach <machenbach@chromium.org> > Cr-Commit-Position: refs/heads/master@{#53230} TBR=machenbach@chromium.org,hablich@chromium.org,sergiyb@chromium.org Change-Id: Ia70dc1df7e25e0c8ffd3fafeb97830b5d5f87336 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:843917 Reviewed-on: https://chromium-review.googlesource.com/1064413 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#53238}
2018-05-17 16:24:18 +00:00
if self.Command("gclient", "setdep -r src/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(force=True,
bypass_hooks=True,
cq=self._options.use_commit_queue,
cq_dry_run=self._options.use_dry_run,
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):
self['json_output']['monitoring_state'] = 'success'
print("Congratulations, you have successfully rolled %s into "
"Chromium."
% self["roll"])
# Clean up all temporary files.
Command("rm", "-f %s*" % self._config["PERSISTFILE_BASENAME"])
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."))
parser.add_argument("--last-roll",
help="The git commit ID of the last rolled version. "
"Auto-detected if not specified.")
parser.add_argument("--max-age", default=7, type=int,
help="Maximum age in days of the latest release.")
parser.add_argument("--revision",
help="Revision to roll. Auto-detected if not "
"specified."),
parser.add_argument("--roll", help="Deprecated.",
default=True, action="store_true")
group = parser.add_mutually_exclusive_group()
group.add_argument("--use-commit-queue",
help="Trigger the CQ full run on upload.",
default=False, action="store_true")
group.add_argument("--use-dry-run",
help="Trigger the CQ dry run on upload.",
default=True, action="store_true")
def _ProcessOptions(self, options): # pragma: no cover
if not options.author or not options.reviewer:
print("A reviewer (-r) and an author (-a) are required.")
return False
options.requires_editor = False
options.force = True
options.manual = False
return True
def _Config(self):
return {
"PERSISTFILE_BASENAME": "/tmp/v8-chromium-roll-tempfile",
}
def _Steps(self):
return [
Preparation,
DetectLastRoll,
DetectRevisionToRoll,
PrepareRollCandidate,
SwitchChromium,
UpdateChromiumCheckout,
UploadCL,
CleanUp,
]
if __name__ == "__main__": # pragma: no cover
sys.exit(AutoRoll().Run())