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."
45 push_hash = self.FindLastTrunkPush(
46 branch="origin/master", include_patches=True)
47 self["last_push"] = self.GetCommitPositionNumber(push_hash)
50 class DetectLastRoll(Step):
51 MESSAGE = "Detect commit ID of the last Chromium roll."
54 # Interpret the DEPS file to retrieve the v8 revision.
55 # TODO(machenbach): This should be part or the roll-deps api of
57 Var = lambda var: '%s'
58 exec(FileToText(os.path.join(self._options.chromium, "DEPS")))
59 last_roll = self.GetCommitPositionNumber(vars['v8_revision'])
60 # FIXME(machenbach): When rolling from bleeding edge and from trunk there
61 # be different commit numbers here. Better use version?
62 if int(last_roll) >= int(self["last_push"]):
63 print("There is no newer v8 revision than the one in Chromium (%s)."
68 class CheckClusterFuzz(Step):
69 MESSAGE = "Check ClusterFuzz api for new problems."
72 if not os.path.exists(self.Config("CLUSTERFUZZ_API_KEY_FILE")):
73 print "Skipping ClusterFuzz check. No api key file found."
75 api_key = FileToText(self.Config("CLUSTERFUZZ_API_KEY_FILE"))
76 # Check for open, reproducible issues that have no associated bug.
77 result = self._side_effect_handler.ReadClusterFuzzAPI(
78 api_key, job_type="linux_asan_d8_dbg", reproducible="True",
79 open="True", bug_information="",
80 revision_greater_or_equal=str(self["last_push"]))
82 print "Stop due to pending ClusterFuzz issues."
86 class RollChromium(Step):
87 MESSAGE = "Roll V8 into Chromium."
90 if self._options.roll:
92 "--author", self._options.author,
93 "--reviewer", self._options.reviewer,
94 "--chromium", self._options.chromium,
97 if self._options.sheriff:
99 "--sheriff", "--googlers-mapping", self._options.googlers_mapping])
100 if self._options.dry_run:
101 args.extend(["--dry-run"])
102 self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args)
105 class AutoRoll(ScriptsBase):
106 def _PrepareOptions(self, parser):
107 parser.add_argument("-c", "--chromium", required=True,
108 help=("The path to your Chromium src/ "
109 "directory to automate the V8 roll."))
110 parser.add_argument("--roll", help="Call Chromium roll script.",
111 default=False, action="store_true")
113 def _ProcessOptions(self, options): # pragma: no cover
114 if not options.reviewer:
115 print "A reviewer (-r) is required."
117 if not options.author:
118 print "An author (-a) is required."
124 "PERSISTFILE_BASENAME": "/tmp/v8-auto-roll-tempfile",
125 "CLUSTERFUZZ_API_KEY_FILE": ".cf_api_key",
138 if __name__ == "__main__": # pragma: no cover
139 sys.exit(AutoRoll().Run())