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 *
16 class CheckActiveRoll(Step):
17 MESSAGE = "Check active roll."
20 def ContainsChromiumRoll(changes):
21 for change in changes:
22 if change["subject"].startswith("Update V8 to"):
29 "owner": self._options.author,
33 params = urllib.urlencode(params)
34 search_url = "https://codereview.chromium.org/search"
35 result = self.ReadURL(search_url, params, wait_plan=[5, 20])
36 if self.ContainsChromiumRoll(json.loads(result)["results"]):
37 print "Stop due to existing Chromium roll."
41 class DetectLastPush(Step):
42 MESSAGE = "Detect commit ID of the last push to trunk."
46 push_hash = self.FindLastTrunkPush(
47 branch="origin/candidates", include_patches=True)
48 self["last_push"] = self.GetCommitPositionNumber(push_hash)
51 class DetectLastRoll(Step):
52 MESSAGE = "Detect commit ID of the last Chromium roll."
55 # Interpret the DEPS file to retrieve the v8 revision.
56 # TODO(machenbach): This should be part or the roll-deps api of
58 Var = lambda var: '%s'
59 exec(FileToText(os.path.join(self._options.chromium, "DEPS")))
60 last_roll = self.GetCommitPositionNumber(vars['v8_revision'])
61 # FIXME(machenbach): When rolling from bleeding edge and from trunk there
62 # be different commit numbers here. Better use version?
63 if int(last_roll) >= int(self["last_push"]):
64 print("There is no newer v8 revision than the one in Chromium (%s)."
69 class CheckClusterFuzz(Step):
70 MESSAGE = "Check ClusterFuzz api for new problems."
73 if not os.path.exists(self.Config("CLUSTERFUZZ_API_KEY_FILE")):
74 print "Skipping ClusterFuzz check. No api key file found."
76 api_key = FileToText(self.Config("CLUSTERFUZZ_API_KEY_FILE"))
77 # Check for open, reproducible issues that have no associated bug.
78 result = self._side_effect_handler.ReadClusterFuzzAPI(
79 api_key, job_type="linux_asan_d8_dbg", reproducible="True",
80 open="True", bug_information="",
81 revision_greater_or_equal=str(self["last_push"]))
83 print "Stop due to pending ClusterFuzz issues."
87 class RollChromium(Step):
88 MESSAGE = "Roll V8 into Chromium."
91 if self._options.roll:
93 "--author", self._options.author,
94 "--reviewer", self._options.reviewer,
95 "--chromium", self._options.chromium,
98 if self._options.sheriff:
100 "--sheriff", "--googlers-mapping", self._options.googlers_mapping])
101 if self._options.dry_run:
102 args.extend(["--dry-run"])
103 if self._options.work_dir:
104 args.extend(["--work-dir", self._options.work_dir])
105 self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args)
108 class AutoRoll(ScriptsBase):
109 def _PrepareOptions(self, parser):
110 parser.add_argument("-c", "--chromium", required=True,
111 help=("The path to your Chromium src/ "
112 "directory to automate the V8 roll."))
113 parser.add_argument("--roll", help="Call Chromium roll script.",
114 default=False, action="store_true")
116 def _ProcessOptions(self, options): # pragma: no cover
117 if not options.reviewer:
118 print "A reviewer (-r) is required."
120 if not options.author:
121 print "An author (-a) is required."
127 "PERSISTFILE_BASENAME": "/tmp/v8-auto-roll-tempfile",
128 "CLUSTERFUZZ_API_KEY_FILE": ".cf_api_key",
141 if __name__ == "__main__": # pragma: no cover
142 sys.exit(AutoRoll().Run())