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 json
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import urllib
|
|
|
|
|
|
|
|
from common_includes import *
|
|
|
|
import chromium_roll
|
|
|
|
|
|
|
|
|
|
|
|
class CheckActiveRoll(Step):
|
|
|
|
MESSAGE = "Check active roll."
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def ContainsChromiumRoll(changes):
|
|
|
|
for change in changes:
|
|
|
|
if change["subject"].startswith("Update V8 to"):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
params = {
|
|
|
|
"closed": 3,
|
|
|
|
"owner": self._options.author,
|
|
|
|
"limit": 30,
|
|
|
|
"format": "json",
|
|
|
|
}
|
|
|
|
params = urllib.urlencode(params)
|
|
|
|
search_url = "https://codereview.chromium.org/search"
|
|
|
|
result = self.ReadURL(search_url, params, wait_plan=[5, 20])
|
|
|
|
if self.ContainsChromiumRoll(json.loads(result)["results"]):
|
|
|
|
print "Stop due to existing Chromium roll."
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class DetectLastPush(Step):
|
2015-01-26 13:29:23 +00:00
|
|
|
MESSAGE = "Detect commit ID of the last push to candidates."
|
2014-04-02 06:59:25 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2014-11-03 15:39:30 +00:00
|
|
|
self.vc.Fetch()
|
2015-01-26 13:29:23 +00:00
|
|
|
push_hash = self.FindLastCandidatesPush(
|
2014-09-25 08:46:13 +00:00
|
|
|
branch="origin/candidates", include_patches=True)
|
2014-09-04 08:42:21 +00:00
|
|
|
self["last_push"] = self.GetCommitPositionNumber(push_hash)
|
2014-04-02 06:59:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DetectLastRoll(Step):
|
|
|
|
MESSAGE = "Detect commit ID of the last Chromium roll."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
# Interpret the DEPS file to retrieve the v8 revision.
|
2014-09-04 09:56:29 +00:00
|
|
|
# TODO(machenbach): This should be part or the roll-deps api of
|
|
|
|
# depot_tools.
|
2014-04-02 06:59:25 +00:00
|
|
|
Var = lambda var: '%s'
|
2014-09-04 09:56:29 +00:00
|
|
|
exec(FileToText(os.path.join(self._options.chromium, "DEPS")))
|
|
|
|
last_roll = self.GetCommitPositionNumber(vars['v8_revision'])
|
2015-01-26 13:29:23 +00:00
|
|
|
# FIXME(machenbach): When rolling from master and from candidates there
|
|
|
|
# will be different commit numbers here. Better use version?
|
2014-09-04 08:42:21 +00:00
|
|
|
if int(last_roll) >= int(self["last_push"]):
|
2014-04-02 06:59:25 +00:00
|
|
|
print("There is no newer v8 revision than the one in Chromium (%s)."
|
|
|
|
% last_roll)
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2014-06-25 08:17:45 +00:00
|
|
|
class CheckClusterFuzz(Step):
|
|
|
|
MESSAGE = "Check ClusterFuzz api for new problems."
|
|
|
|
|
|
|
|
def RunStep(self):
|
2014-09-23 14:41:36 +00:00
|
|
|
if not os.path.exists(self.Config("CLUSTERFUZZ_API_KEY_FILE")):
|
2014-06-25 08:17:45 +00:00
|
|
|
print "Skipping ClusterFuzz check. No api key file found."
|
|
|
|
return False
|
2014-09-23 14:41:36 +00:00
|
|
|
api_key = FileToText(self.Config("CLUSTERFUZZ_API_KEY_FILE"))
|
2014-06-25 08:17:45 +00:00
|
|
|
# Check for open, reproducible issues that have no associated bug.
|
|
|
|
result = self._side_effect_handler.ReadClusterFuzzAPI(
|
|
|
|
api_key, job_type="linux_asan_d8_dbg", reproducible="True",
|
|
|
|
open="True", bug_information="",
|
2014-06-25 08:44:59 +00:00
|
|
|
revision_greater_or_equal=str(self["last_push"]))
|
2014-06-25 08:17:45 +00:00
|
|
|
if result:
|
|
|
|
print "Stop due to pending ClusterFuzz issues."
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2014-04-02 06:59:25 +00:00
|
|
|
class RollChromium(Step):
|
|
|
|
MESSAGE = "Roll V8 into Chromium."
|
|
|
|
|
|
|
|
def RunStep(self):
|
|
|
|
if self._options.roll:
|
2014-04-08 12:07:49 +00:00
|
|
|
args = [
|
|
|
|
"--author", self._options.author,
|
|
|
|
"--reviewer", self._options.reviewer,
|
|
|
|
"--chromium", self._options.chromium,
|
2014-06-25 08:17:45 +00:00
|
|
|
"--use-commit-queue",
|
2014-04-08 12:07:49 +00:00
|
|
|
]
|
|
|
|
if self._options.sheriff:
|
|
|
|
args.extend([
|
|
|
|
"--sheriff", "--googlers-mapping", self._options.googlers_mapping])
|
2014-09-03 08:29:53 +00:00
|
|
|
if self._options.dry_run:
|
|
|
|
args.extend(["--dry-run"])
|
2014-11-03 09:31:13 +00:00
|
|
|
if self._options.work_dir:
|
|
|
|
args.extend(["--work-dir", self._options.work_dir])
|
2014-09-23 14:41:36 +00:00
|
|
|
self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args)
|
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."))
|
2014-09-03 08:29:53 +00:00
|
|
|
parser.add_argument("--roll", help="Call Chromium roll script.",
|
2014-04-02 06:59:25 +00:00
|
|
|
default=False, action="store_true")
|
|
|
|
|
|
|
|
def _ProcessOptions(self, options): # pragma: no cover
|
|
|
|
if not options.reviewer:
|
|
|
|
print "A reviewer (-r) is required."
|
|
|
|
return False
|
|
|
|
if not options.author:
|
|
|
|
print "An author (-a) is required."
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
def _Config(self):
|
|
|
|
return {
|
|
|
|
"PERSISTFILE_BASENAME": "/tmp/v8-auto-roll-tempfile",
|
|
|
|
"CLUSTERFUZZ_API_KEY_FILE": ".cf_api_key",
|
|
|
|
}
|
|
|
|
|
2014-04-02 06:59:25 +00:00
|
|
|
def _Steps(self):
|
|
|
|
return [
|
|
|
|
CheckActiveRoll,
|
|
|
|
DetectLastPush,
|
|
|
|
DetectLastRoll,
|
2014-06-25 08:17:45 +00:00
|
|
|
CheckClusterFuzz,
|
2014-04-02 06:59:25 +00:00
|
|
|
RollChromium,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": # pragma: no cover
|
2014-09-23 14:41:36 +00:00
|
|
|
sys.exit(AutoRoll().Run())
|