| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 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. | |
| 5 | |
| 6 import argparse | |
| 7 import json | |
| 8 import os | |
| 9 import sys | |
| 10 import urllib | |
| 11 | |
| 12 from common_includes import * | |
| 13 import chromium_roll | |
| 14 | |
| 15 | |
| 16 class CheckActiveRoll(Step): | |
| 17 MESSAGE = "Check active roll." | |
| 18 | |
| 19 @staticmethod | |
| 20 def ContainsChromiumRoll(changes): | |
| 21 for change in changes: | |
| 22 if change["subject"].startswith("Update V8 to"): | |
| 23 return True | |
| 24 return False | |
| 25 | |
| 26 def RunStep(self): | |
| 27 params = { | |
| 28 "closed": 3, | |
| 29 "owner": self._options.author, | |
| 30 "limit": 30, | |
| 31 "format": "json", | |
| 32 } | |
| 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." | |
| 38 return True | |
| 39 | |
| 40 | |
| 41 class DetectLastPush(Step): | |
| 42 MESSAGE = "Detect commit ID of the last push to candidates." | |
| 43 | |
| 44 def RunStep(self): | |
| 45 self.vc.Fetch() | |
| 46 push_hash = self.FindLastCandidatesPush( | |
| 47 branch="origin/candidates", include_patches=True) | |
| 48 self["last_push"] = self.GetCommitPositionNumber(push_hash) | |
| 49 | |
| 50 | |
| 51 class DetectLastRoll(Step): | |
| 52 MESSAGE = "Detect commit ID of the last Chromium roll." | |
| 53 | |
| 54 def RunStep(self): | |
| 55 # Interpret the DEPS file to retrieve the v8 revision. | |
| 56 # TODO(machenbach): This should be part or the roll-deps api of | |
| 57 # depot_tools. | |
| 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 master and from candidates there | |
| 62 # will 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)." | |
| 65 % last_roll) | |
| 66 return True | |
| 67 | |
| 68 | |
| 69 class CheckClusterFuzz(Step): | |
| 70 MESSAGE = "Check ClusterFuzz api for new problems." | |
| 71 | |
| 72 def RunStep(self): | |
| 73 if not os.path.exists(self.Config("CLUSTERFUZZ_API_KEY_FILE")): | |
| 74 print "Skipping ClusterFuzz check. No api key file found." | |
| 75 return False | |
| 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"])) | |
| 82 if result: | |
| 83 print "Stop due to pending ClusterFuzz issues." | |
| 84 return True | |
| 85 | |
| 86 | |
| 87 class RollChromium(Step): | |
| 88 MESSAGE = "Roll V8 into Chromium." | |
| 89 | |
| 90 def RunStep(self): | |
| 91 if self._options.roll: | |
| 92 args = [ | |
| 93 "--author", self._options.author, | |
| 94 "--reviewer", self._options.reviewer, | |
| 95 "--chromium", self._options.chromium, | |
| 96 "--use-commit-queue", | |
| 97 ] | |
| 98 if self._options.sheriff: | |
| 99 args.extend([ | |
| 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) | |
| 106 | |
| 107 | |
| 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") | |
| 115 | |
| 116 def _ProcessOptions(self, options): # pragma: no cover | |
| 117 if not options.reviewer: | |
| 118 print "A reviewer (-r) is required." | |
| 119 return False | |
| 120 if not options.author: | |
| 121 print "An author (-a) is required." | |
| 122 return False | |
| 123 return True | |
| 124 | |
| 125 def _Config(self): | |
| 126 return { | |
| 127 "PERSISTFILE_BASENAME": "/tmp/v8-auto-roll-tempfile", | |
| 128 "CLUSTERFUZZ_API_KEY_FILE": ".cf_api_key", | |
| 129 } | |
| 130 | |
| 131 def _Steps(self): | |
| 132 return [ | |
| 133 CheckActiveRoll, | |
| 134 DetectLastPush, | |
| 135 DetectLastRoll, | |
| 136 CheckClusterFuzz, | |
| 137 RollChromium, | |
| 138 ] | |
| 139 | |
| 140 | |
| 141 if __name__ == "__main__": # pragma: no cover | |
| 142 sys.exit(AutoRoll().Run()) | |
| OLD | NEW |