| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 import urllib | 10 import urllib |
| 11 | 11 |
| 12 from common_includes import * | 12 from common_includes import * |
| 13 import chromium_roll | 13 import chromium_roll |
| 14 | 14 |
| 15 CLUSTERFUZZ_API_KEY_FILE = "CLUSTERFUZZ_API_KEY_FILE" | |
| 16 | |
| 17 CONFIG = { | |
| 18 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", | |
| 19 CLUSTERFUZZ_API_KEY_FILE: ".cf_api_key", | |
| 20 } | |
| 21 | |
| 22 | 15 |
| 23 class CheckActiveRoll(Step): | 16 class CheckActiveRoll(Step): |
| 24 MESSAGE = "Check active roll." | 17 MESSAGE = "Check active roll." |
| 25 | 18 |
| 26 @staticmethod | 19 @staticmethod |
| 27 def ContainsChromiumRoll(changes): | 20 def ContainsChromiumRoll(changes): |
| 28 for change in changes: | 21 for change in changes: |
| 29 if change["subject"].startswith("Update V8 to"): | 22 if change["subject"].startswith("Update V8 to"): |
| 30 return True | 23 return True |
| 31 return False | 24 return False |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 if int(last_roll) >= int(self["last_push"]): | 62 if int(last_roll) >= int(self["last_push"]): |
| 70 print("There is no newer v8 revision than the one in Chromium (%s)." | 63 print("There is no newer v8 revision than the one in Chromium (%s)." |
| 71 % last_roll) | 64 % last_roll) |
| 72 return True | 65 return True |
| 73 | 66 |
| 74 | 67 |
| 75 class CheckClusterFuzz(Step): | 68 class CheckClusterFuzz(Step): |
| 76 MESSAGE = "Check ClusterFuzz api for new problems." | 69 MESSAGE = "Check ClusterFuzz api for new problems." |
| 77 | 70 |
| 78 def RunStep(self): | 71 def RunStep(self): |
| 79 if not os.path.exists(self.Config(CLUSTERFUZZ_API_KEY_FILE)): | 72 if not os.path.exists(self.Config("CLUSTERFUZZ_API_KEY_FILE")): |
| 80 print "Skipping ClusterFuzz check. No api key file found." | 73 print "Skipping ClusterFuzz check. No api key file found." |
| 81 return False | 74 return False |
| 82 api_key = FileToText(self.Config(CLUSTERFUZZ_API_KEY_FILE)) | 75 api_key = FileToText(self.Config("CLUSTERFUZZ_API_KEY_FILE")) |
| 83 # Check for open, reproducible issues that have no associated bug. | 76 # Check for open, reproducible issues that have no associated bug. |
| 84 result = self._side_effect_handler.ReadClusterFuzzAPI( | 77 result = self._side_effect_handler.ReadClusterFuzzAPI( |
| 85 api_key, job_type="linux_asan_d8_dbg", reproducible="True", | 78 api_key, job_type="linux_asan_d8_dbg", reproducible="True", |
| 86 open="True", bug_information="", | 79 open="True", bug_information="", |
| 87 revision_greater_or_equal=str(self["last_push"])) | 80 revision_greater_or_equal=str(self["last_push"])) |
| 88 if result: | 81 if result: |
| 89 print "Stop due to pending ClusterFuzz issues." | 82 print "Stop due to pending ClusterFuzz issues." |
| 90 return True | 83 return True |
| 91 | 84 |
| 92 | 85 |
| 93 class RollChromium(Step): | 86 class RollChromium(Step): |
| 94 MESSAGE = "Roll V8 into Chromium." | 87 MESSAGE = "Roll V8 into Chromium." |
| 95 | 88 |
| 96 def RunStep(self): | 89 def RunStep(self): |
| 97 if self._options.roll: | 90 if self._options.roll: |
| 98 args = [ | 91 args = [ |
| 99 "--author", self._options.author, | 92 "--author", self._options.author, |
| 100 "--reviewer", self._options.reviewer, | 93 "--reviewer", self._options.reviewer, |
| 101 "--chromium", self._options.chromium, | 94 "--chromium", self._options.chromium, |
| 102 "--use-commit-queue", | 95 "--use-commit-queue", |
| 103 ] | 96 ] |
| 104 if self._options.sheriff: | 97 if self._options.sheriff: |
| 105 args.extend([ | 98 args.extend([ |
| 106 "--sheriff", "--googlers-mapping", self._options.googlers_mapping]) | 99 "--sheriff", "--googlers-mapping", self._options.googlers_mapping]) |
| 107 if self._options.dry_run: | 100 if self._options.dry_run: |
| 108 args.extend(["--dry-run"]) | 101 args.extend(["--dry-run"]) |
| 109 R = chromium_roll.ChromiumRoll | 102 self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args) |
| 110 self._side_effect_handler.Call( | |
| 111 R(chromium_roll.CONFIG, self._side_effect_handler).Run, | |
| 112 args) | |
| 113 | 103 |
| 114 | 104 |
| 115 class AutoRoll(ScriptsBase): | 105 class AutoRoll(ScriptsBase): |
| 116 def _PrepareOptions(self, parser): | 106 def _PrepareOptions(self, parser): |
| 117 parser.add_argument("-c", "--chromium", required=True, | 107 parser.add_argument("-c", "--chromium", required=True, |
| 118 help=("The path to your Chromium src/ " | 108 help=("The path to your Chromium src/ " |
| 119 "directory to automate the V8 roll.")) | 109 "directory to automate the V8 roll.")) |
| 120 parser.add_argument("--roll", help="Call Chromium roll script.", | 110 parser.add_argument("--roll", help="Call Chromium roll script.", |
| 121 default=False, action="store_true") | 111 default=False, action="store_true") |
| 122 | 112 |
| 123 def _ProcessOptions(self, options): # pragma: no cover | 113 def _ProcessOptions(self, options): # pragma: no cover |
| 124 if not options.reviewer: | 114 if not options.reviewer: |
| 125 print "A reviewer (-r) is required." | 115 print "A reviewer (-r) is required." |
| 126 return False | 116 return False |
| 127 if not options.author: | 117 if not options.author: |
| 128 print "An author (-a) is required." | 118 print "An author (-a) is required." |
| 129 return False | 119 return False |
| 130 return True | 120 return True |
| 131 | 121 |
| 122 def _Config(self): |
| 123 return { |
| 124 "PERSISTFILE_BASENAME": "/tmp/v8-auto-roll-tempfile", |
| 125 "CLUSTERFUZZ_API_KEY_FILE": ".cf_api_key", |
| 126 } |
| 127 |
| 132 def _Steps(self): | 128 def _Steps(self): |
| 133 return [ | 129 return [ |
| 134 CheckActiveRoll, | 130 CheckActiveRoll, |
| 135 DetectLastPush, | 131 DetectLastPush, |
| 136 DetectLastRoll, | 132 DetectLastRoll, |
| 137 CheckClusterFuzz, | 133 CheckClusterFuzz, |
| 138 RollChromium, | 134 RollChromium, |
| 139 ] | 135 ] |
| 140 | 136 |
| 141 | 137 |
| 142 if __name__ == "__main__": # pragma: no cover | 138 if __name__ == "__main__": # pragma: no cover |
| 143 sys.exit(AutoRoll(CONFIG).Run()) | 139 sys.exit(AutoRoll().Run()) |
| OLD | NEW |