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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 | 49 |
50 class Preparation(Step): | 50 class Preparation(Step): |
51 MESSAGE = "Preparation." | 51 MESSAGE = "Preparation." |
52 | 52 |
53 def RunStep(self): | 53 def RunStep(self): |
54 self.InitialEnvironmentChecks() | 54 self.InitialEnvironmentChecks() |
55 self.CommonPrepare() | 55 self.CommonPrepare() |
56 | 56 |
57 | 57 |
58 class CheckAutoRollSettings(Step): | 58 class CheckAutoPushSettings(Step): |
59 MESSAGE = "Checking settings file." | 59 MESSAGE = "Checking settings file." |
60 | 60 |
61 def RunStep(self): | 61 def RunStep(self): |
62 settings_file = os.path.realpath(self.Config(SETTINGS_LOCATION)) | 62 settings_file = os.path.realpath(self.Config(SETTINGS_LOCATION)) |
63 if os.path.exists(settings_file): | 63 if os.path.exists(settings_file): |
64 settings_dict = json.loads(FileToText(settings_file)) | 64 settings_dict = json.loads(FileToText(settings_file)) |
65 if settings_dict.get("enable_auto_roll") is False: | 65 if settings_dict.get("enable_auto_roll") is False: |
66 self.Die("Push to trunk disabled by auto-roll settings file: %s" | 66 self.Die("Push to trunk disabled by auto-roll settings file: %s" |
67 % settings_file) | 67 % settings_file) |
68 | 68 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 # improved by counting only the revisions on bleeding_edge. | 107 # improved by counting only the revisions on bleeding_edge. |
108 if int(self["lkgr"]) - int(last_push_be) < 10: # pragma: no cover | 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 | 109 # This makes sure the script doesn't push twice in a row when the cron |
110 # job retries several times. | 110 # job retries several times. |
111 self.Die("Last push too recently: %s" % last_push_be) | 111 self.Die("Last push too recently: %s" % last_push_be) |
112 | 112 |
113 | 113 |
114 class PushToTrunk(Step): | 114 class PushToTrunk(Step): |
115 MESSAGE = "Pushing to trunk if specified." | 115 MESSAGE = "Pushing to trunk if specified." |
116 | 116 |
117 def PushTreeStatus(self, message): | |
118 if not self._options.status_password: | |
119 print "Skipping tree status update without password file." | |
120 return | |
121 params = { | |
122 "message": message, | |
123 "username": "v8-auto-roll@chromium.org", | |
124 "password": FileToText(self._options.status_password).strip(), | |
125 } | |
126 params = urllib.urlencode(params) | |
127 print "Pushing tree status: '%s'" % message | |
128 self.ReadURL("https://v8-status.appspot.com/status", params, | |
129 wait_plan=[5, 20]) | |
130 | |
131 def RunStep(self): | 117 def RunStep(self): |
132 print "Pushing lkgr %s to trunk." % self["lkgr"] | 118 print "Pushing lkgr %s to trunk." % self["lkgr"] |
133 self.PushTreeStatus("Tree is closed (preparing to push)") | |
134 | 119 |
135 # TODO(machenbach): Update the script before calling it. | 120 # TODO(machenbach): Update the script before calling it. |
136 try: | 121 if self._options.push: |
137 if self._options.push: | 122 P = push_to_trunk.PushToTrunk |
138 P = push_to_trunk.PushToTrunk | 123 self._side_effect_handler.Call( |
139 self._side_effect_handler.Call( | 124 P(push_to_trunk.CONFIG, self._side_effect_handler).Run, |
140 P(push_to_trunk.CONFIG, self._side_effect_handler).Run, | 125 ["--author", self._options.author, |
141 ["--author", self._options.author, | 126 "--reviewer", self._options.reviewer, |
142 "--reviewer", self._options.reviewer, | 127 "--revision", self["lkgr"], |
143 "--revision", self["lkgr"], | 128 "--force"]) |
144 "--force"]) | |
145 finally: | |
146 self.PushTreeStatus(self["tree_message"]) | |
147 | 129 |
148 | 130 |
149 class AutoRoll(ScriptsBase): | 131 class AutoPush(ScriptsBase): |
150 def _PrepareOptions(self, parser): | 132 def _PrepareOptions(self, parser): |
151 parser.add_argument("-c", "--chromium", | |
152 help=("Deprecated.")) | |
153 parser.add_argument("-p", "--push", | 133 parser.add_argument("-p", "--push", |
154 help="Push to trunk. Dry run if unspecified.", | 134 help="Push to trunk. Dry run if unspecified.", |
155 default=False, action="store_true") | 135 default=False, action="store_true") |
156 parser.add_argument("--status-password", | |
157 help="A file with the password to the status app.") | |
158 | 136 |
159 def _ProcessOptions(self, options): | 137 def _ProcessOptions(self, options): |
160 if not options.author or not options.reviewer: # pragma: no cover | 138 if not options.author or not options.reviewer: # pragma: no cover |
161 print "You need to specify author and reviewer." | 139 print "You need to specify author and reviewer." |
162 return False | 140 return False |
163 options.requires_editor = False | 141 options.requires_editor = False |
164 return True | 142 return True |
165 | 143 |
166 def _Steps(self): | 144 def _Steps(self): |
167 return [ | 145 return [ |
168 Preparation, | 146 Preparation, |
169 CheckAutoRollSettings, | 147 CheckAutoPushSettings, |
170 CheckTreeStatus, | 148 CheckTreeStatus, |
171 FetchLKGR, | 149 FetchLKGR, |
172 CheckLastPush, | 150 CheckLastPush, |
173 PushToTrunk, | 151 PushToTrunk, |
174 ] | 152 ] |
175 | 153 |
176 | 154 |
177 if __name__ == "__main__": # pragma: no cover | 155 if __name__ == "__main__": # pragma: no cover |
178 sys.exit(AutoRoll(CONFIG).Run()) | 156 sys.exit(AutoPush(CONFIG).Run()) |
OLD | NEW |