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

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

Issue 873213002: Clean up release scripts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | tools/push-to-trunk/auto_roll.py » ('j') | tools/push-to-trunk/releases.py » ('J')
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 28 matching lines...) Expand all
39 PUSH_MESSAGE_RE = re.compile(r".* \(based on ([a-fA-F0-9]+)\)$") 39 PUSH_MESSAGE_RE = re.compile(r".* \(based on ([a-fA-F0-9]+)\)$")
40 40
41 class Preparation(Step): 41 class Preparation(Step):
42 MESSAGE = "Preparation." 42 MESSAGE = "Preparation."
43 43
44 def RunStep(self): 44 def RunStep(self):
45 self.InitialEnvironmentChecks(self.default_cwd) 45 self.InitialEnvironmentChecks(self.default_cwd)
46 self.CommonPrepare() 46 self.CommonPrepare()
47 47
48 48
49 class CheckAutoPushSettings(Step):
50 MESSAGE = "Checking settings file."
51
52 def RunStep(self):
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"
58 % settings_file)
59
60
61 class CheckTreeStatus(Step):
62 MESSAGE = "Checking v8 tree status message."
63
64 def RunStep(self):
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"])
71
72
73 class FetchCandidate(Step): 49 class FetchCandidate(Step):
74 MESSAGE = "Fetching V8 roll candidate ref." 50 MESSAGE = "Fetching V8 roll candidate ref."
75 51
76 def RunStep(self): 52 def RunStep(self):
77 self.Git("fetch origin +refs/heads/candidate:refs/heads/candidate") 53 self.Git("fetch origin +refs/heads/candidate:refs/heads/candidate")
78 self["candidate"] = self.Git("show-ref -s refs/heads/candidate").strip() 54 self["candidate"] = self.Git("show-ref -s refs/heads/candidate").strip()
79 55
80 56
81 class CheckLastPush(Step): 57 class CheckLastPush(Step):
82 MESSAGE = "Checking last V8 push to trunk." 58 MESSAGE = "Checking last V8 push to candidates."
83 59
84 def RunStep(self): 60 def RunStep(self):
85 last_push = self.FindLastTrunkPush() 61 last_push = self.FindLastCandidatesPush()
86 62
87 # Retrieve the bleeding edge revision of the last push from the text in 63 # Retrieve the master revision of the last push from the text in
88 # the push commit message. 64 # the push commit message.
89 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push) 65 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
90 last_push_be = PUSH_MESSAGE_RE.match(last_push_title).group(1) 66 candidate = PUSH_MESSAGE_RE.match(last_push_title).group(1)
91 67
92 if not last_push_be: # pragma: no cover 68 if not candidate: # pragma: no cover
93 self.Die("Could not retrieve bleeding edge revision for trunk push %s" 69 self.Die("Could not retrieve master revision for candidates push %s"
94 % last_push) 70 % last_push)
95 71
96 if self["candidate"] == last_push_be: 72 if self["candidate"] == candidate:
97 print "Already pushed current candidate %s" % last_push_be 73 print "Already pushed current candidate %s" % candidate
98 return True 74 return True
99 75
100 76
101 class PushToCandidates(Step): 77 class PushToCandidates(Step):
102 MESSAGE = "Pushing to candidates if specified." 78 MESSAGE = "Pushing to candidates if specified."
103 79
104 def RunStep(self): 80 def RunStep(self):
105 print "Pushing candidate %s to candidates." % self["candidate"] 81 print "Pushing candidate %s to candidates." % self["candidate"]
106 82
107 args = [ 83 args = [
108 "--author", self._options.author, 84 "--author", self._options.author,
109 "--reviewer", self._options.reviewer, 85 "--reviewer", self._options.reviewer,
110 "--revision", self["candidate"], 86 "--revision", self["candidate"],
111 "--force", 87 "--force",
112 ] 88 ]
113 89
114 if self._options.work_dir: 90 if self._options.work_dir:
115 args.extend(["--work-dir", self._options.work_dir]) 91 args.extend(["--work-dir", self._options.work_dir])
116 92
117 # TODO(machenbach): Update the script before calling it. 93 # TODO(machenbach): Update the script before calling it.
118 if self._options.push: 94 if self._options.push:
119 self._side_effect_handler.Call(push_to_trunk.PushToTrunk().Run, args) 95 self._side_effect_handler.Call(
96 push_to_trunk.PushToCandidates().Run, args)
120 97
121 98
122 class AutoPush(ScriptsBase): 99 class AutoPush(ScriptsBase):
123 def _PrepareOptions(self, parser): 100 def _PrepareOptions(self, parser):
124 parser.add_argument("-p", "--push", 101 parser.add_argument("-p", "--push",
125 help="Push to trunk. Dry run if unspecified.", 102 help="Push to candidates. Dry run if unspecified.",
126 default=False, action="store_true") 103 default=False, action="store_true")
127 104
128 def _ProcessOptions(self, options): 105 def _ProcessOptions(self, options):
129 if not options.author or not options.reviewer: # pragma: no cover 106 if not options.author or not options.reviewer: # pragma: no cover
130 print "You need to specify author and reviewer." 107 print "You need to specify author and reviewer."
131 return False 108 return False
132 options.requires_editor = False 109 options.requires_editor = False
133 return True 110 return True
134 111
135 def _Config(self): 112 def _Config(self):
136 return { 113 return {
137 "PERSISTFILE_BASENAME": "/tmp/v8-auto-push-tempfile", 114 "PERSISTFILE_BASENAME": "/tmp/v8-auto-push-tempfile",
138 "SETTINGS_LOCATION": "~/.auto-roll",
139 } 115 }
140 116
141 def _Steps(self): 117 def _Steps(self):
142 return [ 118 return [
143 Preparation, 119 Preparation,
144 CheckAutoPushSettings,
145 CheckTreeStatus,
146 FetchCandidate, 120 FetchCandidate,
147 CheckLastPush, 121 CheckLastPush,
148 PushToCandidates, 122 PushToCandidates,
149 ] 123 ]
150 124
151 125
152 if __name__ == "__main__": # pragma: no cover 126 if __name__ == "__main__": # pragma: no cover
153 sys.exit(AutoPush().Run()) 127 sys.exit(AutoPush().Run())
OLDNEW
« no previous file with comments | « no previous file | tools/push-to-trunk/auto_roll.py » ('j') | tools/push-to-trunk/releases.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698