Chromium Code Reviews| 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 | 15 |
| 16 class CheckActiveRoll(Step): | |
|
Michael Achenbach
2015/11/20 13:55:49
Removing this here as it is already done on the re
| |
| 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 DetectLastRoll(Step): | 16 class DetectLastRoll(Step): |
| 42 MESSAGE = "Detect commit ID of the last Chromium roll." | 17 MESSAGE = "Detect commit ID of the last Chromium roll." |
| 43 | 18 |
| 44 def RunStep(self): | 19 def RunStep(self): |
| 45 # The revision that should be rolled. Check for the latest of the most | 20 # The revision that should be rolled. Check for the latest of the most |
| 46 # recent releases based on commit timestamp. | 21 # recent releases based on commit timestamp. |
| 47 revisions = self.GetRecentReleases( | 22 revisions = self.GetRecentReleases( |
| 48 max_age=self._options.max_age * DAY_IN_SECONDS) | 23 max_age=self._options.max_age * DAY_IN_SECONDS) |
| 49 assert revisions, "Didn't find any recent release." | 24 assert revisions, "Didn't find any recent release." |
| 50 | 25 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 "--last-roll", self["last_roll"], | 64 "--last-roll", self["last_roll"], |
| 90 "--use-commit-queue", | 65 "--use-commit-queue", |
| 91 self["roll"], | 66 self["roll"], |
| 92 ] | 67 ] |
| 93 if self._options.sheriff: | 68 if self._options.sheriff: |
| 94 args.append("--sheriff") | 69 args.append("--sheriff") |
| 95 if self._options.dry_run: | 70 if self._options.dry_run: |
| 96 args.append("--dry-run") | 71 args.append("--dry-run") |
| 97 if self._options.work_dir: | 72 if self._options.work_dir: |
| 98 args.extend(["--work-dir", self._options.work_dir]) | 73 args.extend(["--work-dir", self._options.work_dir]) |
| 74 if self._options.chromium_roll_json_output: | |
| 75 args.extend(["--json-output", self._options.chromium_roll_json_output]) | |
| 99 self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args) | 76 self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args) |
| 100 | 77 |
| 101 | 78 |
| 102 class AutoRoll(ScriptsBase): | 79 class AutoRoll(ScriptsBase): |
| 103 def _PrepareOptions(self, parser): | 80 def _PrepareOptions(self, parser): |
| 104 parser.add_argument("-c", "--chromium", required=True, | 81 parser.add_argument("-c", "--chromium", required=True, |
| 105 help=("The path to your Chromium src/ " | 82 help=("The path to your Chromium src/ " |
| 106 "directory to automate the V8 roll.")) | 83 "directory to automate the V8 roll.")) |
| 84 parser.add_argument("--chromium-roll-json-output", | |
| 85 help="File to write wrapped results summary to.") | |
| 107 parser.add_argument("--max-age", default=3, type=int, | 86 parser.add_argument("--max-age", default=3, type=int, |
| 108 help="Maximum age in days of the latest release.") | 87 help="Maximum age in days of the latest release.") |
| 109 parser.add_argument("--roll", help="Call Chromium roll script.", | 88 parser.add_argument("--roll", help="Call Chromium roll script.", |
| 110 default=False, action="store_true") | 89 default=False, action="store_true") |
| 111 | 90 |
| 112 def _ProcessOptions(self, options): # pragma: no cover | 91 def _ProcessOptions(self, options): # pragma: no cover |
| 113 if not options.reviewer: | 92 if not options.reviewer: |
| 114 print "A reviewer (-r) is required." | 93 print "A reviewer (-r) is required." |
| 115 return False | 94 return False |
| 116 if not options.author: | 95 if not options.author: |
| 117 print "An author (-a) is required." | 96 print "An author (-a) is required." |
| 118 return False | 97 return False |
| 119 return True | 98 return True |
| 120 | 99 |
| 121 def _Config(self): | 100 def _Config(self): |
| 122 return { | 101 return { |
| 123 "PERSISTFILE_BASENAME": "/tmp/v8-auto-roll-tempfile", | 102 "PERSISTFILE_BASENAME": "/tmp/v8-auto-roll-tempfile", |
| 124 } | 103 } |
| 125 | 104 |
| 126 def _Steps(self): | 105 def _Steps(self): |
| 127 return [ | 106 return [ |
| 128 CheckActiveRoll, | |
| 129 DetectLastRoll, | 107 DetectLastRoll, |
| 130 RollChromium, | 108 RollChromium, |
| 131 ] | 109 ] |
| 132 | 110 |
| 133 | 111 |
| 134 if __name__ == "__main__": # pragma: no cover | 112 if __name__ == "__main__": # pragma: no cover |
| 135 sys.exit(AutoRoll().Run()) | 113 sys.exit(AutoRoll().Run()) |
| OLD | NEW |