2 # Copyright 2013 the V8 project authors. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following
11 # disclaimer in the documentation and/or other materials provided
12 # with the distribution.
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived
15 # from this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 from common_includes import *
39 PUSH_MESSAGE_RE = re.compile(r".* \(based on ([a-fA-F0-9]+)\)$")
41 class Preparation(Step):
42 MESSAGE = "Preparation."
45 self.InitialEnvironmentChecks(self.default_cwd)
49 class CheckAutoPushSettings(Step):
50 MESSAGE = "Checking settings file."
53 settings_file = os.path.realpath(self.Config("SETTINGS_LOCATION"))
54 if os.path.exists(settings_file):
55 settings_dict = json.loads(FileToText(settings_file))
56 if settings_dict.get("enable_auto_roll") is False:
57 self.Die("Push to trunk disabled by auto-roll settings file: %s"
61 class CheckTreeStatus(Step):
62 MESSAGE = "Checking v8 tree status message."
65 status_url = "https://v8-status.appspot.com/current?format=json"
66 status_json = self.ReadURL(status_url, wait_plan=[5, 20, 300, 300])
67 self["tree_message"] = json.loads(status_json)["message"]
68 if re.search(r"nopush|no push", self["tree_message"], flags=re.I):
69 self.Die("Push to trunk disabled by tree state: %s"
70 % self["tree_message"])
73 class FetchLKGR(Step):
74 MESSAGE = "Fetching V8 LKGR."
77 lkgr_url = "https://v8-status.appspot.com/lkgr"
78 # Retry several times since app engine might have issues.
79 self["lkgr"] = self.ReadURL(lkgr_url, wait_plan=[5, 20, 300, 300])
82 class CheckLastPush(Step):
83 MESSAGE = "Checking last V8 push to trunk."
86 last_push = self.FindLastTrunkPush()
88 # Retrieve the bleeding edge revision of the last push from the text in
89 # the push commit message.
90 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
91 last_push_be = PUSH_MESSAGE_RE.match(last_push_title).group(1)
93 if not last_push_be: # pragma: no cover
94 self.Die("Could not retrieve bleeding edge revision for trunk push %s"
97 if self["lkgr"] == last_push_be:
98 print "Already pushed current lkgr %s" % last_push_be
102 class PushToCandidates(Step):
103 MESSAGE = "Pushing to candidates if specified."
106 print "Pushing lkgr %s to candidates." % self["lkgr"]
109 "--author", self._options.author,
110 "--reviewer", self._options.reviewer,
111 "--revision", self["lkgr"],
115 if self._options.svn:
116 args.extend(["--svn", self._options.svn])
117 if self._options.svn_config:
118 args.extend(["--svn-config", self._options.svn_config])
119 if self._options.vc_interface:
120 args.extend(["--vc-interface", self._options.vc_interface])
121 if self._options.work_dir:
122 args.extend(["--work-dir", self._options.work_dir])
124 # TODO(machenbach): Update the script before calling it.
125 if self._options.push:
126 self._side_effect_handler.Call(push_to_trunk.PushToTrunk().Run, args)
129 class AutoPush(ScriptsBase):
130 def _PrepareOptions(self, parser):
131 parser.add_argument("-p", "--push",
132 help="Push to trunk. Dry run if unspecified.",
133 default=False, action="store_true")
135 def _ProcessOptions(self, options):
136 if not options.author or not options.reviewer: # pragma: no cover
137 print "You need to specify author and reviewer."
139 options.requires_editor = False
144 "PERSISTFILE_BASENAME": "/tmp/v8-auto-push-tempfile",
145 "SETTINGS_LOCATION": "~/.auto-roll",
151 CheckAutoPushSettings,
159 if __name__ == "__main__": # pragma: no cover
160 sys.exit(AutoPush().Run())