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 """ | 6 """ |
7 Script for auto-increasing the version on bleeding_edge. | 7 Script for auto-increasing the version on bleeding_edge. |
8 | 8 |
9 The script can be run regularly by a cron job. It will increase the build | 9 The script can be run regularly by a cron job. It will increase the build |
10 level of the version on bleeding_edge if: | 10 level of the version on bleeding_edge if: |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 class Preparation(Step): | 31 class Preparation(Step): |
32 MESSAGE = "Preparation." | 32 MESSAGE = "Preparation." |
33 | 33 |
34 def RunStep(self): | 34 def RunStep(self): |
35 # Check for a clean workdir. | 35 # Check for a clean workdir. |
36 if not self.GitIsWorkdirClean(): # pragma: no cover | 36 if not self.GitIsWorkdirClean(): # pragma: no cover |
37 # This is in case a developer runs this script on a dirty tree. | 37 # This is in case a developer runs this script on a dirty tree. |
38 self.GitStash() | 38 self.GitStash() |
39 | 39 |
40 # TODO(machenbach): This should be called master after the git switch. | 40 self.GitCheckout("master") |
41 self.GitCheckout("bleeding_edge") | |
42 | 41 |
43 self.GitPull() | 42 self.GitPull() |
44 | 43 |
45 # Ensure a clean version branch. | 44 # Ensure a clean version branch. |
46 self.DeleteBranch(VERSION_BRANCH) | 45 self.DeleteBranch(VERSION_BRANCH) |
47 | 46 |
48 | 47 |
49 class GetCurrentBleedingEdgeVersion(Step): | 48 class GetCurrentBleedingEdgeVersion(Step): |
50 MESSAGE = "Get latest bleeding edge version." | 49 MESSAGE = "Get latest bleeding edge version." |
51 | 50 |
52 def RunStep(self): | 51 def RunStep(self): |
53 # TODO(machenbach): This should be called master after the git switch. | 52 self.GitCheckout("master") |
54 self.GitCheckout("bleeding_edge") | |
55 | 53 |
56 # Store latest version and revision. | 54 # Store latest version and revision. |
57 self.ReadAndPersistVersion() | 55 self.ReadAndPersistVersion() |
58 self["latest_version"] = self.ArrayToVersion("") | 56 self["latest_version"] = self.ArrayToVersion("") |
59 self["latest"] = self.GitLog(n=1, format="%H") | 57 self["latest"] = self.GitLog(n=1, format="%H") |
60 print "Bleeding edge version: %s" % self["latest_version"] | 58 print "Bleeding edge version: %s" % self["latest_version"] |
61 | 59 |
62 | 60 |
63 # This step is pure paranoia. It forbids the script to continue if the last | 61 # This step is pure paranoia. It forbids the script to continue if the last |
64 # commit changed version.cc. Just in case the other bailout has a bug, this | 62 # commit changed version.cc. Just in case the other bailout has a bug, this |
(...skipping 16 matching lines...) Expand all Loading... |
81 self["lkgr_svn"] = self.ReadURL(lkgr_url, wait_plan=[5]) | 79 self["lkgr_svn"] = self.ReadURL(lkgr_url, wait_plan=[5]) |
82 | 80 |
83 | 81 |
84 # TODO(machenbach): Implement this for git. With a git lkgr we could simply | 82 # TODO(machenbach): Implement this for git. With a git lkgr we could simply |
85 # checkout that revision. With svn, we have to search backwards until that | 83 # checkout that revision. With svn, we have to search backwards until that |
86 # revision is found. | 84 # revision is found. |
87 class GetLKGRVersion(Step): | 85 class GetLKGRVersion(Step): |
88 MESSAGE = "Get bleeding edge lkgr version." | 86 MESSAGE = "Get bleeding edge lkgr version." |
89 | 87 |
90 def RunStep(self): | 88 def RunStep(self): |
91 self.GitCheckout("bleeding_edge") | 89 self.GitCheckout("master") |
92 # If the commit was made from svn, there is a mapping entry in the commit | 90 # If the commit was made from svn, there is a mapping entry in the commit |
93 # message. | 91 # message. |
94 self["lkgr"] = self.GitLog( | 92 self["lkgr"] = self.GitLog( |
95 grep="^git-svn-id: [^@]*@%s [A-Za-z0-9-]*$" % self["lkgr_svn"], | 93 grep="^git-svn-id: [^@]*@%s [A-Za-z0-9-]*$" % self["lkgr_svn"], |
96 format="%H") | 94 format="%H") |
97 | 95 |
98 # FIXME(machenbach): http://crbug.com/391712 can lead to svn lkgrs on the | 96 # FIXME(machenbach): http://crbug.com/391712 can lead to svn lkgrs on the |
99 # trunk branch (rarely). | 97 # trunk branch (rarely). |
100 if not self["lkgr"]: # pragma: no cover | 98 if not self["lkgr"]: # pragma: no cover |
101 self.Die("No git hash found for svn lkgr.") | 99 self.Die("No git hash found for svn lkgr.") |
102 | 100 |
103 self.GitCreateBranch(VERSION_BRANCH, self["lkgr"]) | 101 self.GitCreateBranch(VERSION_BRANCH, self["lkgr"]) |
104 self.ReadAndPersistVersion("lkgr_") | 102 self.ReadAndPersistVersion("lkgr_") |
105 self["lkgr_version"] = self.ArrayToVersion("lkgr_") | 103 self["lkgr_version"] = self.ArrayToVersion("lkgr_") |
106 print "LKGR version: %s" % self["lkgr_version"] | 104 print "LKGR version: %s" % self["lkgr_version"] |
107 | 105 |
108 # Ensure a clean version branch. | 106 # Ensure a clean version branch. |
109 self.GitCheckout("bleeding_edge") | 107 self.GitCheckout("master") |
110 self.DeleteBranch(VERSION_BRANCH) | 108 self.DeleteBranch(VERSION_BRANCH) |
111 | 109 |
112 | 110 |
113 class LKGRVersionUpToDateBailout(Step): | 111 class LKGRVersionUpToDateBailout(Step): |
114 MESSAGE = "Stop script if the lkgr has a renewed version." | 112 MESSAGE = "Stop script if the lkgr has a renewed version." |
115 | 113 |
116 def RunStep(self): | 114 def RunStep(self): |
117 # If a version-change commit becomes the lkgr, don't bump up the version | 115 # If a version-change commit becomes the lkgr, don't bump up the version |
118 # again. | 116 # again. |
119 if VERSION_FILE in self.GitChangedFiles(self["lkgr"]): | 117 if VERSION_FILE in self.GitChangedFiles(self["lkgr"]): |
120 print "Stop because the lkgr is a version change itself." | 118 print "Stop because the lkgr is a version change itself." |
121 return True | 119 return True |
122 | 120 |
123 # Don't bump up the version if it got updated already after the lkgr. | 121 # Don't bump up the version if it got updated already after the lkgr. |
124 if SortingKey(self["lkgr_version"]) < SortingKey(self["latest_version"]): | 122 if SortingKey(self["lkgr_version"]) < SortingKey(self["latest_version"]): |
125 print("Stop because the latest version already changed since the lkgr " | 123 print("Stop because the latest version already changed since the lkgr " |
126 "version.") | 124 "version.") |
127 return True | 125 return True |
128 | 126 |
129 | 127 |
130 class GetTrunkVersion(Step): | 128 class GetTrunkVersion(Step): |
131 MESSAGE = "Get latest trunk version." | 129 MESSAGE = "Get latest trunk version." |
132 | 130 |
133 def RunStep(self): | 131 def RunStep(self): |
134 # TODO(machenbach): This should be called trunk after the git switch. | 132 self.GitCheckout("candidates") |
135 self.GitCheckout("master") | |
136 self.GitPull() | 133 self.GitPull() |
137 self.ReadAndPersistVersion("trunk_") | 134 self.ReadAndPersistVersion("trunk_") |
138 self["trunk_version"] = self.ArrayToVersion("trunk_") | 135 self["trunk_version"] = self.ArrayToVersion("trunk_") |
139 print "Trunk version: %s" % self["trunk_version"] | 136 print "Trunk version: %s" % self["trunk_version"] |
140 | 137 |
141 | 138 |
142 class CalculateVersion(Step): | 139 class CalculateVersion(Step): |
143 MESSAGE = "Calculate the new version." | 140 MESSAGE = "Calculate the new version." |
144 | 141 |
145 def RunStep(self): | 142 def RunStep(self): |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 message = json.loads(status_json)["message"] | 176 message = json.loads(status_json)["message"] |
180 if re.search(r"maintenance|no commits", message, flags=re.I): | 177 if re.search(r"maintenance|no commits", message, flags=re.I): |
181 print "Skip version change by tree status: \"%s\"" % message | 178 print "Skip version change by tree status: \"%s\"" % message |
182 return True | 179 return True |
183 | 180 |
184 | 181 |
185 class ChangeVersion(Step): | 182 class ChangeVersion(Step): |
186 MESSAGE = "Bump up the version." | 183 MESSAGE = "Bump up the version." |
187 | 184 |
188 def RunStep(self): | 185 def RunStep(self): |
189 self.GitCreateBranch(VERSION_BRANCH, "bleeding_edge") | 186 self.GitCreateBranch(VERSION_BRANCH, "master") |
190 | 187 |
191 self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_") | 188 self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_") |
192 | 189 |
193 try: | 190 try: |
194 msg = "[Auto-roll] Bump up version to %s" % self["new_version"] | 191 msg = "[Auto-roll] Bump up version to %s" % self["new_version"] |
195 self.GitCommit("%s\n\nTBR=%s" % (msg, self._options.author), | 192 self.GitCommit("%s\n\nTBR=%s" % (msg, self._options.author), |
196 author=self._options.author) | 193 author=self._options.author) |
197 if self._options.svn: | 194 if self._options.svn: |
198 self.SVNCommit("branches/bleeding_edge", msg) | 195 self.SVNCommit("branches/bleeding_edge", msg) |
199 else: | 196 else: |
200 self.GitUpload(author=self._options.author, | 197 self.GitUpload(author=self._options.author, |
201 force=self._options.force_upload, | 198 force=self._options.force_upload, |
202 bypass_hooks=True) | 199 bypass_hooks=True) |
203 self.GitDCommit() | 200 self.GitDCommit() |
204 print "Successfully changed the version." | 201 print "Successfully changed the version." |
205 finally: | 202 finally: |
206 # Clean up. | 203 # Clean up. |
207 self.GitCheckout("bleeding_edge") | 204 self.GitCheckout("master") |
208 self.DeleteBranch(VERSION_BRANCH) | 205 self.DeleteBranch(VERSION_BRANCH) |
209 | 206 |
210 | 207 |
211 class BumpUpVersion(ScriptsBase): | 208 class BumpUpVersion(ScriptsBase): |
212 def _PrepareOptions(self, parser): | 209 def _PrepareOptions(self, parser): |
213 parser.add_argument("--dry_run", help="Don't commit the new version.", | 210 parser.add_argument("--dry_run", help="Don't commit the new version.", |
214 default=False, action="store_true") | 211 default=False, action="store_true") |
215 | 212 |
216 def _ProcessOptions(self, options): # pragma: no cover | 213 def _ProcessOptions(self, options): # pragma: no cover |
217 if not options.dry_run and not options.author: | 214 if not options.dry_run and not options.author: |
(...skipping 18 matching lines...) Expand all Loading... |
236 GetLKGRVersion, | 233 GetLKGRVersion, |
237 LKGRVersionUpToDateBailout, | 234 LKGRVersionUpToDateBailout, |
238 GetTrunkVersion, | 235 GetTrunkVersion, |
239 CalculateVersion, | 236 CalculateVersion, |
240 CheckTreeStatus, | 237 CheckTreeStatus, |
241 ChangeVersion, | 238 ChangeVersion, |
242 ] | 239 ] |
243 | 240 |
244 if __name__ == "__main__": # pragma: no cover | 241 if __name__ == "__main__": # pragma: no cover |
245 sys.exit(BumpUpVersion().Run()) | 242 sys.exit(BumpUpVersion().Run()) |
OLD | NEW |