2 # Copyright 2014 the V8 project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
12 from common_includes import *
15 CLUSTERFUZZ_API_KEY_FILE = "CLUSTERFUZZ_API_KEY_FILE"
18 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile",
19 CLUSTERFUZZ_API_KEY_FILE: ".cf_api_key",
22 CR_DEPS_URL = 'http://src.chromium.org/svn/trunk/src/DEPS'
24 class CheckActiveRoll(Step):
25 MESSAGE = "Check active roll."
28 def ContainsChromiumRoll(changes):
29 for change in changes:
30 if change["subject"].startswith("Update V8 to"):
37 "owner": self._options.author,
41 params = urllib.urlencode(params)
42 search_url = "https://codereview.chromium.org/search"
43 result = self.ReadURL(search_url, params, wait_plan=[5, 20])
44 if self.ContainsChromiumRoll(json.loads(result)["results"]):
45 print "Stop due to existing Chromium roll."
49 class DetectLastPush(Step):
50 MESSAGE = "Detect commit ID of the last push to trunk."
53 push_hash = self.FindLastTrunkPush(include_patches=True)
54 self["last_push"] = self.GitSVNFindSVNRev(push_hash)
57 class DetectLastRoll(Step):
58 MESSAGE = "Detect commit ID of the last Chromium roll."
61 # Interpret the DEPS file to retrieve the v8 revision.
62 Var = lambda var: '%s'
63 exec(self.ReadURL(CR_DEPS_URL))
64 last_roll = vars['v8_revision']
65 if last_roll >= self["last_push"]:
66 print("There is no newer v8 revision than the one in Chromium (%s)."
71 class CheckClusterFuzz(Step):
72 MESSAGE = "Check ClusterFuzz api for new problems."
75 if not os.path.exists(self.Config(CLUSTERFUZZ_API_KEY_FILE)):
76 print "Skipping ClusterFuzz check. No api key file found."
78 api_key = FileToText(self.Config(CLUSTERFUZZ_API_KEY_FILE))
79 # Check for open, reproducible issues that have no associated bug.
80 result = self._side_effect_handler.ReadClusterFuzzAPI(
81 api_key, job_type="linux_asan_d8_dbg", reproducible="True",
82 open="True", bug_information="",
83 revision_greater_or_equal=str(self["last_push"]))
85 print "Stop due to pending ClusterFuzz issues."
89 class RollChromium(Step):
90 MESSAGE = "Roll V8 into Chromium."
93 if self._options.roll:
95 "--author", self._options.author,
96 "--reviewer", self._options.reviewer,
97 "--chromium", self._options.chromium,
101 if self._options.sheriff:
103 "--sheriff", "--googlers-mapping", self._options.googlers_mapping])
104 R = chromium_roll.ChromiumRoll
105 self._side_effect_handler.Call(
106 R(chromium_roll.CONFIG, self._side_effect_handler).Run,
110 class AutoRoll(ScriptsBase):
111 def _PrepareOptions(self, parser):
112 parser.add_argument("-c", "--chromium", required=True,
113 help=("The path to your Chromium src/ "
114 "directory to automate the V8 roll."))
115 parser.add_argument("--roll",
116 help="Make Chromium roll. Dry run if unspecified.",
117 default=False, action="store_true")
119 def _ProcessOptions(self, options): # pragma: no cover
120 if not options.reviewer:
121 print "A reviewer (-r) is required."
123 if not options.author:
124 print "An author (-a) is required."
138 if __name__ == "__main__": # pragma: no cover
139 sys.exit(AutoRoll(CONFIG).Run())