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

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

Issue 205703004: Let auto-roll push the lkgr. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review 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 | « no previous file | tools/push-to-trunk/test_scripts.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 26 matching lines...) Expand all
37 import push_to_trunk 37 import push_to_trunk
38 38
39 SETTINGS_LOCATION = "SETTINGS_LOCATION" 39 SETTINGS_LOCATION = "SETTINGS_LOCATION"
40 40
41 CONFIG = { 41 CONFIG = {
42 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", 42 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile",
43 DOT_GIT_LOCATION: ".git", 43 DOT_GIT_LOCATION: ".git",
44 SETTINGS_LOCATION: "~/.auto-roll", 44 SETTINGS_LOCATION: "~/.auto-roll",
45 } 45 }
46 46
47 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
48
47 49
48 class Preparation(Step): 50 class Preparation(Step):
49 MESSAGE = "Preparation." 51 MESSAGE = "Preparation."
50 52
51 def RunStep(self): 53 def RunStep(self):
52 self.InitialEnvironmentChecks() 54 self.InitialEnvironmentChecks()
53 self.CommonPrepare() 55 self.CommonPrepare()
54 56
55 57
56 class CheckAutoRollSettings(Step): 58 class CheckAutoRollSettings(Step):
(...skipping 13 matching lines...) Expand all
70 72
71 def RunStep(self): 73 def RunStep(self):
72 status_url = "https://v8-status.appspot.com/current?format=json" 74 status_url = "https://v8-status.appspot.com/current?format=json"
73 status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300]) 75 status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300])
74 self["tree_message"] = json.loads(status_json)["message"] 76 self["tree_message"] = json.loads(status_json)["message"]
75 if re.search(r"nopush|no push", self["tree_message"], flags=re.I): 77 if re.search(r"nopush|no push", self["tree_message"], flags=re.I):
76 self.Die("Push to trunk disabled by tree state: %s" 78 self.Die("Push to trunk disabled by tree state: %s"
77 % self["tree_message"]) 79 % self["tree_message"])
78 80
79 81
80 class FetchLatestRevision(Step):
81 MESSAGE = "Fetching latest V8 revision."
82
83 def RunStep(self):
84 match = re.match(r"^r(\d+) ", self.GitSVNLog())
85 if not match: # pragma: no cover
86 self.Die("Could not extract current svn revision from log.")
87 self["latest"] = match.group(1)
88
89
90 class CheckLastPush(Step):
91 MESSAGE = "Checking last V8 push to trunk."
92
93 def RunStep(self):
94 last_push_hash = self.FindLastTrunkPush()
95 last_push = int(self.GitSVNFindSVNRev(last_push_hash))
96
97 # TODO(machenbach): This metric counts all revisions. It could be
98 # improved by counting only the revisions on bleeding_edge.
99 if int(self["latest"]) - last_push < 10: # pragma: no cover
100 # This makes sure the script doesn't push twice in a row when the cron
101 # job retries several times.
102 self.Die("Last push too recently: %d" % last_push)
103
104
105 class FetchLKGR(Step): 82 class FetchLKGR(Step):
106 MESSAGE = "Fetching V8 LKGR." 83 MESSAGE = "Fetching V8 LKGR."
107 84
108 def RunStep(self): 85 def RunStep(self):
109 lkgr_url = "https://v8-status.appspot.com/lkgr" 86 lkgr_url = "https://v8-status.appspot.com/lkgr"
110 # Retry several times since app engine might have issues. 87 # Retry several times since app engine might have issues.
111 self["lkgr"] = self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300]) 88 self["lkgr"] = self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300])
112 89
113 90
91 class CheckLastPush(Step):
92 MESSAGE = "Checking last V8 push to trunk."
93
94 def RunStep(self):
95 last_push = self.FindLastTrunkPush()
96
97 # Retrieve the bleeding edge revision of the last push from the text in
98 # the push commit message.
99 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
100 last_push_be = PUSH_MESSAGE_RE.match(last_push_title).group(1)
101
102 if not last_push_be: # pragma: no cover
103 self.Die("Could not retrieve bleeding edge revision for trunk push %s"
104 % last_push)
105
106 # TODO(machenbach): This metric counts all revisions. It could be
107 # improved by counting only the revisions on bleeding_edge.
108 if int(self["lkgr"]) - int(last_push_be) < 10: # pragma: no cover
109 # This makes sure the script doesn't push twice in a row when the cron
110 # job retries several times.
111 self.Die("Last push too recently: %s" % last_push_be)
112
113
114 class PushToTrunk(Step): 114 class PushToTrunk(Step):
115 MESSAGE = "Pushing to trunk if possible." 115 MESSAGE = "Pushing to trunk if specified."
116 116
117 def PushTreeStatus(self, message): 117 def PushTreeStatus(self, message):
118 if not self._options.status_password: 118 if not self._options.status_password:
119 print "Skipping tree status update without password file." 119 print "Skipping tree status update without password file."
120 return 120 return
121 params = { 121 params = {
122 "message": message, 122 "message": message,
123 "username": "v8-auto-roll@chromium.org", 123 "username": "v8-auto-roll@chromium.org",
124 "password": FileToText(self._options.status_password).strip(), 124 "password": FileToText(self._options.status_password).strip(),
125 } 125 }
126 params = urllib.urlencode(params) 126 params = urllib.urlencode(params)
127 print "Pushing tree status: '%s'" % message 127 print "Pushing tree status: '%s'" % message
128 self.ReadURL("https://v8-status.appspot.com/status", params, 128 self.ReadURL("https://v8-status.appspot.com/status", params,
129 wait_plan=[5, 20]) 129 wait_plan=[5, 20])
130 130
131 def RunStep(self): 131 def RunStep(self):
132 latest = int(self["latest"]) 132 print "Pushing lkgr %s to trunk." % self["lkgr"]
133 lkgr = int(self["lkgr"]) 133 self.PushTreeStatus("Tree is closed (preparing to push)")
134 if latest == lkgr:
135 print "ToT (r%d) is clean. Pushing to trunk." % latest
136 self.PushTreeStatus("Tree is closed (preparing to push)")
137 134
138 # TODO(machenbach): Update the script before calling it. 135 # TODO(machenbach): Update the script before calling it.
139 try: 136 try:
140 if self._options.push: 137 if self._options.push:
141 P = push_to_trunk.PushToTrunk 138 P = push_to_trunk.PushToTrunk
142 self._side_effect_handler.Call( 139 self._side_effect_handler.Call(
143 P(push_to_trunk.CONFIG, self._side_effect_handler).Run, 140 P(push_to_trunk.CONFIG, self._side_effect_handler).Run,
144 ["-a", self._options.author, 141 ["-author", self._options.author,
145 "-r", self._options.reviewer, 142 "-reviewer", self._options.reviewer,
146 "-f"]) 143 "-revision", self["lkgr"],
147 finally: 144 "-force"])
148 self.PushTreeStatus(self["tree_message"]) 145 finally:
149 else: 146 self.PushTreeStatus(self["tree_message"])
150 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk."
151 % (latest, lkgr))
152 147
153 148
154 class AutoRoll(ScriptsBase): 149 class AutoRoll(ScriptsBase):
155 def _PrepareOptions(self, parser): 150 def _PrepareOptions(self, parser):
156 parser.add_argument("-c", "--chromium", 151 parser.add_argument("-c", "--chromium",
157 help=("Deprecated.")) 152 help=("Deprecated."))
158 parser.add_argument("-p", "--push", 153 parser.add_argument("-p", "--push",
159 help="Push to trunk. Dry run if unspecified.", 154 help="Push to trunk. Dry run if unspecified.",
160 default=False, action="store_true") 155 default=False, action="store_true")
161 parser.add_argument("--status-password", 156 parser.add_argument("--status-password",
162 help="A file with the password to the status app.") 157 help="A file with the password to the status app.")
163 158
164 def _ProcessOptions(self, options): 159 def _ProcessOptions(self, options):
165 if not options.author or not options.reviewer: # pragma: no cover 160 if not options.author or not options.reviewer: # pragma: no cover
166 print "You need to specify author and reviewer." 161 print "You need to specify author and reviewer."
167 return False 162 return False
168 options.requires_editor = False 163 options.requires_editor = False
169 return True 164 return True
170 165
171 def _Steps(self): 166 def _Steps(self):
172 return [ 167 return [
173 Preparation, 168 Preparation,
174 CheckAutoRollSettings, 169 CheckAutoRollSettings,
175 CheckTreeStatus, 170 CheckTreeStatus,
176 FetchLatestRevision, 171 FetchLKGR,
177 CheckLastPush, 172 CheckLastPush,
178 FetchLKGR,
179 PushToTrunk, 173 PushToTrunk,
180 ] 174 ]
181 175
182 176
183 if __name__ == "__main__": # pragma: no cover 177 if __name__ == "__main__": # pragma: no cover
184 sys.exit(AutoRoll(CONFIG).Run()) 178 sys.exit(AutoRoll(CONFIG).Run())
OLDNEW
« no previous file with comments | « no previous file | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698