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

Side by Side Diff: recipe_modules/bot_update/api.py

Issue 1686273002: Bot update cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 4 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
iannucci 2016/02/11 00:56:20 can't comment on patch.exe directly, but can we ma
hinoka 2016/02/11 20:10:05 Done.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 """Recipe module to ensure a checkout is consistant on a bot.""" 6 """Recipe module to ensure a checkout is consistant on a bot."""
7 7
8 from recipe_engine import recipe_api 8 from recipe_engine import recipe_api
9 9
10 10
11 # This is just for testing, to indicate if a master is using a Git scheduler
12 # or not.
13 SVN_MASTERS = (
14 'experimental.svn',
15 )
16
17 11
18 def jsonish_to_python(spec, is_top=False): 12 def jsonish_to_python(spec, is_top=False):
19 """Turn a json spec into a python parsable object. 13 """Turn a json spec into a python parsable object.
20 14
21 This exists because Gclient specs, while resembling json, is actually 15 This exists because Gclient specs, while resembling json, is actually
22 ingested using a python "eval()". Therefore a bit of plumming is required 16 ingested using a python "eval()". Therefore a bit of plumming is required
23 to turn our newly constructed Gclient spec into a gclient-readable spec. 17 to turn our newly constructed Gclient spec into a gclient-readable spec.
24 """ 18 """
25 ret = '' 19 ret = ''
26 if is_top: # We're the 'top' level, so treat this dict as a suite. 20 if is_top: # We're the 'top' level, so treat this dict as a suite.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 kwargs['env']['PATH'] = self.m.path.pathsep.join([ 56 kwargs['env']['PATH'] = self.m.path.pathsep.join([
63 kwargs['env']['PATH'], str(self._module.PACKAGE_DIRECTORY)]) 57 kwargs['env']['PATH'], str(self._module.PACKAGE_DIRECTORY)])
64 return self.m.python(name, bot_update_path, cmd, **kwargs) 58 return self.m.python(name, bot_update_path, cmd, **kwargs)
65 59
66 @property 60 @property
67 def properties(self): 61 def properties(self):
68 return self._properties 62 return self._properties
69 63
70 def ensure_checkout(self, gclient_config=None, suffix=None, 64 def ensure_checkout(self, gclient_config=None, suffix=None,
71 patch=True, update_presentation=True, 65 patch=True, update_presentation=True,
72 force=False, patch_root=None, no_shallow=False, 66 force=True, patch_root=None, no_shallow=False,
iannucci 2016/02/11 00:56:20 this CL: docstring indicate that this option is ig
hinoka 2016/02/11 20:10:05 Acknowledged.
73 with_branch_heads=False, refs=None, 67 with_branch_heads=False, refs=None,
74 patch_project_roots=None, patch_oauth2=False, 68 patch_project_roots=None, patch_oauth2=False,
75 output_manifest=True, clobber=False, 69 output_manifest=True, clobber=False,
76 root_solution_revision=None, **kwargs): 70 root_solution_revision=None, **kwargs):
77 refs = refs or [] 71 refs = refs or []
78 # We can re-use the gclient spec from the gclient module, since all the 72 # We can re-use the gclient spec from the gclient module, since all the
79 # data bot_update needs is already configured into the gclient spec. 73 # data bot_update needs is already configured into the gclient spec.
80 cfg = gclient_config or self.m.gclient.c 74 cfg = gclient_config or self.m.gclient.c
81 spec_string = jsonish_to_python(cfg.as_jsonish(), True) 75 spec_string = jsonish_to_python(cfg.as_jsonish(), True)
82 76
83 # Used by bot_update to determine if we want to run or not.
84 master = self.m.properties['mastername']
85 builder = self.m.properties['buildername']
86 slave = self.m.properties['slavename']
87
88 # Construct our bot_update command. This basically be inclusive of 77 # Construct our bot_update command. This basically be inclusive of
89 # everything required for bot_update to know: 78 # everything required for bot_update to know:
90 root = patch_root 79 root = patch_root
91 if root is None: 80 if root is None:
92 root = cfg.solutions[0].name 81 root = cfg.solutions[0].name
93 additional = self.m.rietveld.calculate_issue_root(patch_project_roots) 82 additional = self.m.rietveld.calculate_issue_root(patch_project_roots)
94 if additional: 83 if additional:
95 root = self.m.path.join(root, additional) 84 root = self.m.path.join(root, additional)
96 85
97 if patch: 86 if patch:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 key_file = self.m.path['build'].join( 118 key_file = self.m.path['build'].join(
130 'site_config', '.rietveld_secret_key') 119 'site_config', '.rietveld_secret_key')
131 else: 120 else:
132 email_file = key_file = None 121 email_file = key_file = None
133 122
134 rev_map = {} 123 rev_map = {}
135 if self.m.gclient.c: 124 if self.m.gclient.c:
136 rev_map = self.m.gclient.c.got_revision_mapping.as_jsonish() 125 rev_map = self.m.gclient.c.got_revision_mapping.as_jsonish()
137 126
138 flags = [ 127 flags = [
139 # 1. Do we want to run? (master/builder/slave). 128 # 1. What do we want to check out (spec/root/rev/rev_map).
140 ['--master', master],
141 ['--builder', builder],
142 ['--slave', slave],
143
144 # 2. What do we want to check out (spec/root/rev/rev_map).
145 ['--spec', spec_string], 129 ['--spec', spec_string],
146 ['--root', root], 130 ['--root', root],
147 ['--revision_mapping_file', self.m.json.input(rev_map)], 131 ['--revision_mapping_file', self.m.json.input(rev_map)],
148 ['--git-cache-dir', self.m.path['git_cache']], 132 ['--git-cache-dir', self.m.path['git_cache']],
149 133
150 # 3. How to find the patch, if any (issue/patchset/patch_url). 134 # 2. How to find the patch, if any (issue/patchset/patch_url).
151 ['--issue', issue], 135 ['--issue', issue],
152 ['--patchset', patchset], 136 ['--patchset', patchset],
153 ['--patch_url', patch_url], 137 ['--patch_url', patch_url],
154 ['--rietveld_server', self.m.properties.get('rietveld')], 138 ['--rietveld_server', self.m.properties.get('rietveld')],
155 ['--gerrit_repo', gerrit_repo], 139 ['--gerrit_repo', gerrit_repo],
156 ['--gerrit_ref', gerrit_ref], 140 ['--gerrit_ref', gerrit_ref],
157 ['--apply_issue_email_file', email_file], 141 ['--apply_issue_email_file', email_file],
158 ['--apply_issue_key_file', key_file], 142 ['--apply_issue_key_file', key_file],
159 143
160 # 4. Hookups to JSON output back into recipes. 144 # 3. Hookups to JSON output back into recipes.
161 ['--output_json', self.m.json.output()],] 145 ['--output_json', self.m.json.output()],]
162 146
163 147
164 # Collect all fixed revisions to simulate them in the json output. 148 # Collect all fixed revisions to simulate them in the json output.
165 # Fixed revision are the explicit input revisions of bot_update.py, i.e. 149 # Fixed revision are the explicit input revisions of bot_update.py, i.e.
166 # every command line parameter "--revision name@value". 150 # every command line parameter "--revision name@value".
167 fixed_revisions = {} 151 fixed_revisions = {}
168 152
169 revisions = {} 153 revisions = {}
170 for solution in cfg.solutions: 154 for solution in cfg.solutions:
(...skipping 19 matching lines...) Expand all
190 # Add extra fetch refspecs. 174 # Add extra fetch refspecs.
191 for ref in refs: 175 for ref in refs:
192 flags.append(['--refs', ref]) 176 flags.append(['--refs', ref])
193 177
194 # Filter out flags that are None. 178 # Filter out flags that are None.
195 cmd = [item for flag_set in flags 179 cmd = [item for flag_set in flags
196 for item in flag_set if flag_set[1] is not None] 180 for item in flag_set if flag_set[1] is not None]
197 181
198 if clobber: 182 if clobber:
199 cmd.append('--clobber') 183 cmd.append('--clobber')
200 if force:
201 cmd.append('--force')
202 if no_shallow: 184 if no_shallow:
203 cmd.append('--no_shallow') 185 cmd.append('--no_shallow')
204 if output_manifest: 186 if output_manifest:
205 cmd.append('--output_manifest') 187 cmd.append('--output_manifest')
206 if with_branch_heads or cfg.with_branch_heads: 188 if with_branch_heads or cfg.with_branch_heads:
207 cmd.append('--with_branch_heads') 189 cmd.append('--with_branch_heads')
208 190
209 # Inject Json output for testing. 191 # Inject Json output for testing.
210 git_mode = self.m.properties.get('mastername') not in SVN_MASTERS
211 first_sln = cfg.solutions[0].name 192 first_sln = cfg.solutions[0].name
212 step_test_data = lambda: self.test_api.output_json( 193 step_test_data = lambda: self.test_api.output_json(
213 master, builder, slave, root, first_sln, rev_map, git_mode, force, 194 root, first_sln, rev_map, self.m.properties.get('fail_patch', False),
214 self.m.properties.get('fail_patch', False),
215 output_manifest=output_manifest, fixed_revisions=fixed_revisions) 195 output_manifest=output_manifest, fixed_revisions=fixed_revisions)
216 196
217 # Add suffixes to the step name, if specified. 197 # Add suffixes to the step name, if specified.
218 name = 'bot_update' 198 name = 'bot_update'
219 if not patch: 199 if not patch:
220 name += ' (without patch)' 200 name += ' (without patch)'
221 if suffix: 201 if suffix:
222 name += ' - %s' % suffix 202 name += ' - %s' % suffix
223 203
224 # Ah hah! Now that everything is in place, lets run bot_update! 204 # Ah hah! Now that everything is in place, lets run bot_update!
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 252
273 # bot_update actually just sets root to be the folder name of the 253 # bot_update actually just sets root to be the folder name of the
274 # first solution. 254 # first solution.
275 if step_result.json.output['did_run']: 255 if step_result.json.output['did_run']:
276 co_root = step_result.json.output['root'] 256 co_root = step_result.json.output['root']
277 cwd = kwargs.get('cwd', self.m.path['slave_build']) 257 cwd = kwargs.get('cwd', self.m.path['slave_build'])
278 if 'checkout' not in self.m.path: 258 if 'checkout' not in self.m.path:
279 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) 259 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep))
280 260
281 return step_result 261 return step_result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698