Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: tools/push-to-trunk/auto_roll.py

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gyp/v8.gyp ('k') | tools/push-to-trunk/common_includes.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 the V8 project authors. All rights reserved. 2 # Copyright 2013 the V8 project authors. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 17 matching lines...) Expand all
28 28
29 import argparse 29 import argparse
30 import json 30 import json
31 import os 31 import os
32 import re 32 import re
33 import sys 33 import sys
34 import urllib 34 import urllib
35 35
36 from common_includes import * 36 from common_includes import *
37 import push_to_trunk 37 import push_to_trunk
38 from push_to_trunk import PushToTrunkOptions
39 from push_to_trunk import RunPushToTrunk
40 38
41 SETTINGS_LOCATION = "SETTINGS_LOCATION" 39 SETTINGS_LOCATION = "SETTINGS_LOCATION"
42 40
43 CONFIG = { 41 CONFIG = {
44 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", 42 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile",
45 DOT_GIT_LOCATION: ".git", 43 DOT_GIT_LOCATION: ".git",
46 SETTINGS_LOCATION: "~/.auto-roll", 44 SETTINGS_LOCATION: "~/.auto-roll",
47 } 45 }
48 46
49 47
50 class AutoRollOptions(CommonOptions):
51 def __init__(self, options):
52 super(AutoRollOptions, self).__init__(options)
53 self.requires_editor = False
54 self.status_password = options.status_password
55 self.chromium = options.chromium
56 self.push = getattr(options, 'push', False)
57 self.author = getattr(options, 'author', None)
58
59
60 class Preparation(Step): 48 class Preparation(Step):
61 MESSAGE = "Preparation." 49 MESSAGE = "Preparation."
62 50
63 def RunStep(self): 51 def RunStep(self):
64 self.InitialEnvironmentChecks() 52 self.InitialEnvironmentChecks()
65 self.CommonPrepare() 53 self.CommonPrepare()
66 54
67 55
68 class CheckAutoRollSettings(Step): 56 class CheckAutoRollSettings(Step):
69 MESSAGE = "Checking settings file." 57 MESSAGE = "Checking settings file."
(...skipping 17 matching lines...) Expand all
87 if re.search(r"nopush|no push", self["tree_message"], flags=re.I): 75 if re.search(r"nopush|no push", self["tree_message"], flags=re.I):
88 self.Die("Push to trunk disabled by tree state: %s" 76 self.Die("Push to trunk disabled by tree state: %s"
89 % self["tree_message"]) 77 % self["tree_message"])
90 78
91 79
92 class FetchLatestRevision(Step): 80 class FetchLatestRevision(Step):
93 MESSAGE = "Fetching latest V8 revision." 81 MESSAGE = "Fetching latest V8 revision."
94 82
95 def RunStep(self): 83 def RunStep(self):
96 match = re.match(r"^r(\d+) ", self.GitSVNLog()) 84 match = re.match(r"^r(\d+) ", self.GitSVNLog())
97 if not match: 85 if not match: # pragma: no cover
98 self.Die("Could not extract current svn revision from log.") 86 self.Die("Could not extract current svn revision from log.")
99 self["latest"] = match.group(1) 87 self["latest"] = match.group(1)
100 88
101 89
102 class CheckLastPush(Step): 90 class CheckLastPush(Step):
103 MESSAGE = "Checking last V8 push to trunk." 91 MESSAGE = "Checking last V8 push to trunk."
104 92
105 def RunStep(self): 93 def RunStep(self):
106 last_push_hash = self.FindLastTrunkPush() 94 last_push_hash = self.FindLastTrunkPush()
107 last_push = int(self.GitSVNFindSVNRev(last_push_hash)) 95 last_push = int(self.GitSVNFindSVNRev(last_push_hash))
108 96
109 # TODO(machenbach): This metric counts all revisions. It could be 97 # TODO(machenbach): This metric counts all revisions. It could be
110 # improved by counting only the revisions on bleeding_edge. 98 # improved by counting only the revisions on bleeding_edge.
111 if int(self["latest"]) - last_push < 10: 99 if int(self["latest"]) - last_push < 10: # pragma: no cover
112 # This makes sure the script doesn't push twice in a row when the cron 100 # This makes sure the script doesn't push twice in a row when the cron
113 # job retries several times. 101 # job retries several times.
114 self.Die("Last push too recently: %d" % last_push) 102 self.Die("Last push too recently: %d" % last_push)
115 103
116 104
117 class FetchLKGR(Step): 105 class FetchLKGR(Step):
118 MESSAGE = "Fetching V8 LKGR." 106 MESSAGE = "Fetching V8 LKGR."
119 107
120 def RunStep(self): 108 def RunStep(self):
121 lkgr_url = "https://v8-status.appspot.com/lkgr" 109 lkgr_url = "https://v8-status.appspot.com/lkgr"
(...skipping 21 matching lines...) Expand all
143 def RunStep(self): 131 def RunStep(self):
144 latest = int(self["latest"]) 132 latest = int(self["latest"])
145 lkgr = int(self["lkgr"]) 133 lkgr = int(self["lkgr"])
146 if latest == lkgr: 134 if latest == lkgr:
147 print "ToT (r%d) is clean. Pushing to trunk." % latest 135 print "ToT (r%d) is clean. Pushing to trunk." % latest
148 self.PushTreeStatus("Tree is closed (preparing to push)") 136 self.PushTreeStatus("Tree is closed (preparing to push)")
149 137
150 # TODO(machenbach): Update the script before calling it. 138 # TODO(machenbach): Update the script before calling it.
151 try: 139 try:
152 if self._options.push: 140 if self._options.push:
141 P = push_to_trunk.PushToTrunk
153 self._side_effect_handler.Call( 142 self._side_effect_handler.Call(
154 RunPushToTrunk, 143 P(push_to_trunk.CONFIG, self._side_effect_handler).Run,
155 push_to_trunk.CONFIG, 144 ["-a", self._options.author,
156 PushToTrunkOptions.MakeForcedOptions(self._options.author, 145 "-c", self._options.chromium,
157 self._options.reviewer, 146 "-r", self._options.reviewer,
158 self._options.chromium), 147 "-f"])
159 self._side_effect_handler)
160 finally: 148 finally:
161 self.PushTreeStatus(self["tree_message"]) 149 self.PushTreeStatus(self["tree_message"])
162 else: 150 else:
163 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." 151 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk."
164 % (latest, lkgr)) 152 % (latest, lkgr))
165 153
166 154
167 def RunAutoRoll(config, 155 class AutoRoll(ScriptsBase):
168 options, 156 def _PrepareOptions(self, parser):
169 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): 157 parser.add_argument("-c", "--chromium", required=True,
170 step_classes = [ 158 help=("The path to your Chromium src/ "
171 Preparation, 159 "directory to automate the V8 roll."))
172 CheckAutoRollSettings, 160 parser.add_argument("-p", "--push",
173 CheckTreeStatus, 161 help="Push to trunk. Dry run if unspecified.",
174 FetchLatestRevision, 162 default=False, action="store_true")
175 CheckLastPush, 163 parser.add_argument("--status-password",
176 FetchLKGR, 164 help="A file with the password to the status app.")
177 PushToTrunk, 165
178 ] 166 def _ProcessOptions(self, options):
179 RunScript(step_classes, config, options, side_effect_handler) 167 if not options.author or not options.reviewer: # pragma: no cover
168 print "You need to specify author and reviewer."
169 return False
170 options.requires_editor = False
171 return True
172
173 def _Steps(self):
174 return [
175 Preparation,
176 CheckAutoRollSettings,
177 CheckTreeStatus,
178 FetchLatestRevision,
179 CheckLastPush,
180 FetchLKGR,
181 PushToTrunk,
182 ]
180 183
181 184
182 def BuildOptions(): 185 if __name__ == "__main__": # pragma: no cover
183 parser = argparse.ArgumentParser() 186 sys.exit(AutoRoll(CONFIG).Run())
184 parser.add_argument("-a", "--author",
185 help="The author email used for rietveld.")
186 parser.add_argument("-c", "--chromium",
187 help=("The path to your Chromium src/ directory to "
188 "automate the V8 roll."))
189 parser.add_argument("-p", "--push",
190 help="Push to trunk if possible. Dry run if unspecified.",
191 default=False, action="store_true")
192 parser.add_argument("-r", "--reviewer",
193 help="The account name to be used for reviews.")
194 parser.add_argument("-s", "--step",
195 help="Specify the step where to start work. Default: 0.",
196 default=0, type=int)
197 parser.add_argument("--status-password",
198 help="A file with the password to the status app.")
199 return parser
200
201
202 def Main():
203 parser = BuildOptions()
204 options = parser.parse_args()
205 if not options.author or not options.chromium or not options.reviewer:
206 print "You need to specify author, chromium src location and reviewer."
207 parser.print_help()
208 return 1
209 RunAutoRoll(CONFIG, AutoRollOptions(options))
210
211 if __name__ == "__main__":
212 sys.exit(Main())
OLDNEW
« no previous file with comments | « tools/gyp/v8.gyp ('k') | tools/push-to-trunk/common_includes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698