OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 self.Die("Push to trunk disabled by auto-roll settings file: %s" | 76 self.Die("Push to trunk disabled by auto-roll settings file: %s" |
77 % settings_file) | 77 % settings_file) |
78 | 78 |
79 | 79 |
80 class CheckTreeStatus(Step): | 80 class CheckTreeStatus(Step): |
81 MESSAGE = "Checking v8 tree status message." | 81 MESSAGE = "Checking v8 tree status message." |
82 | 82 |
83 def RunStep(self): | 83 def RunStep(self): |
84 status_url = "https://v8-status.appspot.com/current?format=json" | 84 status_url = "https://v8-status.appspot.com/current?format=json" |
85 status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300]) | 85 status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300]) |
86 message = json.loads(status_json)["message"] | 86 self["tree_message"] = json.loads(status_json)["message"] |
87 if re.search(r"nopush|no push", message, flags=re.I): | 87 if re.search(r"nopush|no push", self["tree_message"], flags=re.I): |
88 self.Die("Push to trunk disabled by tree state: %s" % message) | 88 self.Die("Push to trunk disabled by tree state: %s" |
89 self.Persist("tree_message", message) | 89 % self["tree_message"]) |
90 | 90 |
91 | 91 |
92 class FetchLatestRevision(Step): | 92 class FetchLatestRevision(Step): |
93 MESSAGE = "Fetching latest V8 revision." | 93 MESSAGE = "Fetching latest V8 revision." |
94 | 94 |
95 def RunStep(self): | 95 def RunStep(self): |
96 log = self.Git("svn log -1 --oneline").strip() | 96 log = self.Git("svn log -1 --oneline").strip() |
97 match = re.match(r"^r(\d+) ", log) | 97 match = re.match(r"^r(\d+) ", log) |
98 if not match: | 98 if not match: |
99 self.Die("Could not extract current svn revision from log.") | 99 self.Die("Could not extract current svn revision from log.") |
100 self.Persist("latest", match.group(1)) | 100 self["latest"] = match.group(1) |
101 | 101 |
102 | 102 |
103 class CheckLastPush(Step): | 103 class CheckLastPush(Step): |
104 MESSAGE = "Checking last V8 push to trunk." | 104 MESSAGE = "Checking last V8 push to trunk." |
105 | 105 |
106 def RunStep(self): | 106 def RunStep(self): |
107 self.RestoreIfUnset("latest") | |
108 log = self.Git("svn log -1 --oneline ChangeLog").strip() | 107 log = self.Git("svn log -1 --oneline ChangeLog").strip() |
109 match = re.match(r"^r(\d+) \| Prepare push to trunk", log) | 108 match = re.match(r"^r(\d+) \| Prepare push to trunk", log) |
110 if match: | 109 if match: |
111 latest = int(self._state["latest"]) | 110 latest = int(self["latest"]) |
112 last_push = int(match.group(1)) | 111 last_push = int(match.group(1)) |
113 # TODO(machebach): This metric counts all revisions. It could be | 112 # TODO(machebach): This metric counts all revisions. It could be |
114 # improved by counting only the revisions on bleeding_edge. | 113 # improved by counting only the revisions on bleeding_edge. |
115 if latest - last_push < 10: | 114 if latest - last_push < 10: |
116 # This makes sure the script doesn't push twice in a row when the cron | 115 # This makes sure the script doesn't push twice in a row when the cron |
117 # job retries several times. | 116 # job retries several times. |
118 self.Die("Last push too recently: %d" % last_push) | 117 self.Die("Last push too recently: %d" % last_push) |
119 | 118 |
120 | 119 |
121 class FetchLKGR(Step): | 120 class FetchLKGR(Step): |
122 MESSAGE = "Fetching V8 LKGR." | 121 MESSAGE = "Fetching V8 LKGR." |
123 | 122 |
124 def RunStep(self): | 123 def RunStep(self): |
125 lkgr_url = "https://v8-status.appspot.com/lkgr" | 124 lkgr_url = "https://v8-status.appspot.com/lkgr" |
126 # Retry several times since app engine might have issues. | 125 # Retry several times since app engine might have issues. |
127 self.Persist("lkgr", self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300])) | 126 self["lkgr"] = self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300]) |
128 | 127 |
129 | 128 |
130 class PushToTrunk(Step): | 129 class PushToTrunk(Step): |
131 MESSAGE = "Pushing to trunk if possible." | 130 MESSAGE = "Pushing to trunk if possible." |
132 | 131 |
133 def PushTreeStatus(self, message): | 132 def PushTreeStatus(self, message): |
134 if not self._options.status_password: | 133 if not self._options.status_password: |
135 print "Skipping tree status update without password file." | 134 print "Skipping tree status update without password file." |
136 return | 135 return |
137 params = { | 136 params = { |
138 "message": message, | 137 "message": message, |
139 "username": "v8-auto-roll@chromium.org", | 138 "username": "v8-auto-roll@chromium.org", |
140 "password": FileToText(self._options.status_password).strip(), | 139 "password": FileToText(self._options.status_password).strip(), |
141 } | 140 } |
142 params = urllib.urlencode(params) | 141 params = urllib.urlencode(params) |
143 print "Pushing tree status: '%s'" % message | 142 print "Pushing tree status: '%s'" % message |
144 self.ReadURL("https://v8-status.appspot.com/status", params, | 143 self.ReadURL("https://v8-status.appspot.com/status", params, |
145 wait_plan=[5, 20]) | 144 wait_plan=[5, 20]) |
146 | 145 |
147 def RunStep(self): | 146 def RunStep(self): |
148 self.RestoreIfUnset("latest") | 147 latest = int(self["latest"]) |
149 self.RestoreIfUnset("lkgr") | 148 lkgr = int(self["lkgr"]) |
150 self.RestoreIfUnset("tree_message") | |
151 latest = int(self._state["latest"]) | |
152 lkgr = int(self._state["lkgr"]) | |
153 if latest == lkgr: | 149 if latest == lkgr: |
154 print "ToT (r%d) is clean. Pushing to trunk." % latest | 150 print "ToT (r%d) is clean. Pushing to trunk." % latest |
155 self.PushTreeStatus("Tree is closed (preparing to push)") | 151 self.PushTreeStatus("Tree is closed (preparing to push)") |
156 | 152 |
157 # TODO(machenbach): Update the script before calling it. | 153 # TODO(machenbach): Update the script before calling it. |
158 try: | 154 try: |
159 if self._options.push: | 155 if self._options.push: |
160 self._side_effect_handler.Call( | 156 self._side_effect_handler.Call( |
161 RunPushToTrunk, | 157 RunPushToTrunk, |
162 push_to_trunk.CONFIG, | 158 push_to_trunk.CONFIG, |
163 PushToTrunkOptions.MakeForcedOptions(self._options.author, | 159 PushToTrunkOptions.MakeForcedOptions(self._options.author, |
164 self._options.reviewer, | 160 self._options.reviewer, |
165 self._options.c), | 161 self._options.c), |
166 self._side_effect_handler) | 162 self._side_effect_handler) |
167 finally: | 163 finally: |
168 self.PushTreeStatus(self._state["tree_message"]) | 164 self.PushTreeStatus(self["tree_message"]) |
169 else: | 165 else: |
170 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." | 166 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." |
171 % (latest, lkgr)) | 167 % (latest, lkgr)) |
172 | 168 |
173 | 169 |
174 def RunAutoRoll(config, | 170 def RunAutoRoll(config, |
175 options, | 171 options, |
176 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): | 172 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
177 step_classes = [ | 173 step_classes = [ |
178 Preparation, | 174 Preparation, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 parser = BuildOptions() | 206 parser = BuildOptions() |
211 (options, args) = parser.parse_args() | 207 (options, args) = parser.parse_args() |
212 if not options.a or not options.c or not options.reviewer: | 208 if not options.a or not options.c or not options.reviewer: |
213 print "You need to specify author, chromium src location and reviewer." | 209 print "You need to specify author, chromium src location and reviewer." |
214 parser.print_help() | 210 parser.print_help() |
215 return 1 | 211 return 1 |
216 RunAutoRoll(CONFIG, AutoRollOptions(options)) | 212 RunAutoRoll(CONFIG, AutoRollOptions(options)) |
217 | 213 |
218 if __name__ == "__main__": | 214 if __name__ == "__main__": |
219 sys.exit(Main()) | 215 sys.exit(Main()) |
OLD | NEW |