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

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

Issue 2308193002: Remove bogus master/builder/slave/force parameters from bot_update. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
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 class BotUpdateApi(recipe_api.RecipeApi): 11 class BotUpdateApi(recipe_api.RecipeApi):
12 12
13 def __init__(self, mastername, buildername, slavename, issue, patchset, 13 def __init__(self, issue, patchset, patch_url, repository, gerrit_ref,
14 patch_url, repository, gerrit_ref, rietveld, revision, 14 rietveld, revision, parent_got_revision, deps_revision_overrides,
15 parent_got_revision, deps_revision_overrides, fail_patch, 15 fail_patch, *args, **kwargs):
16 *args, **kwargs):
17 self._mastername = mastername
18 self._buildername = buildername
19 self._slavename = slavename
20 self._issue = issue 16 self._issue = issue
21 self._patchset = patchset 17 self._patchset = patchset
22 self._patch_url = patch_url 18 self._patch_url = patch_url
23 self._repository = repository 19 self._repository = repository
24 self._gerrit_ref = gerrit_ref 20 self._gerrit_ref = gerrit_ref
25 self._rietveld = rietveld 21 self._rietveld = rietveld
26 self._revision = revision 22 self._revision = revision
27 self._parent_got_revision = parent_got_revision 23 self._parent_got_revision = parent_got_revision
28 self._deps_revision_overrides = deps_revision_overrides 24 self._deps_revision_overrides = deps_revision_overrides
29 self._fail_patch = fail_patch 25 self._fail_patch = fail_patch
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 '--root', str(root), 59 '--root', str(root),
64 ] 60 ]
65 if gerrit_no_reset: 61 if gerrit_no_reset:
66 cmd.append('--gerrit_no_reset') 62 cmd.append('--gerrit_no_reset')
67 if gerrit_no_rebase_patch_ref or not gerrit_rebase_patch_ref: 63 if gerrit_no_rebase_patch_ref or not gerrit_rebase_patch_ref:
68 cmd.append('--gerrit_no_rebase_patch_ref') 64 cmd.append('--gerrit_no_rebase_patch_ref')
69 return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs) 65 return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs)
70 66
71 def ensure_checkout(self, gclient_config=None, suffix=None, 67 def ensure_checkout(self, gclient_config=None, suffix=None,
72 patch=True, update_presentation=True, 68 patch=True, update_presentation=True,
73 force=False, patch_root=None, no_shallow=False, 69 patch_root=None, no_shallow=False,
74 with_branch_heads=False, refs=None, 70 with_branch_heads=False, refs=None,
75 patch_oauth2=False, use_site_config_creds=True, 71 patch_oauth2=False, use_site_config_creds=True,
76 output_manifest=True, clobber=False, 72 output_manifest=True, clobber=False,
77 root_solution_revision=None, rietveld=None, issue=None, 73 root_solution_revision=None, rietveld=None, issue=None,
78 patchset=None, gerrit_no_reset=False, 74 patchset=None, gerrit_no_reset=False,
79 gerrit_no_rebase_patch_ref=False, 75 gerrit_no_rebase_patch_ref=False,
80 gerrit_rebase_patch_ref=True, **kwargs): 76 gerrit_rebase_patch_ref=True, **kwargs):
81 """ 77 """
82 Args: 78 Args:
83 use_site_config_creds: If the oauth2 credentials are in the buildbot 79 use_site_config_creds: If the oauth2 credentials are in the buildbot
84 site_config. See crbug.com/624212 for more information. 80 site_config. See crbug.com/624212 for more information.
85 gclient_config: The gclient configuration to use when running bot_update. 81 gclient_config: The gclient configuration to use when running bot_update.
86 If omitted, the current gclient configuration is used. 82 If omitted, the current gclient configuration is used.
87 rietveld: The rietveld server to use. If omitted, will infer from 83 rietveld: The rietveld server to use. If omitted, will infer from
88 the 'rietveld' property. 84 the 'rietveld' property.
89 issue: The rietveld issue number to use. If omitted, will infer from 85 issue: The rietveld issue number to use. If omitted, will infer from
90 the 'issue' property. 86 the 'issue' property.
91 patchset: The rietveld issue patchset to use. If omitted, will infer from 87 patchset: The rietveld issue patchset to use. If omitted, will infer from
92 the 'patchset' property. 88 the 'patchset' property.
93 """ 89 """
94 refs = refs or [] 90 refs = refs or []
95 # We can re-use the gclient spec from the gclient module, since all the 91 # We can re-use the gclient spec from the gclient module, since all the
96 # data bot_update needs is already configured into the gclient spec. 92 # data bot_update needs is already configured into the gclient spec.
97 cfg = gclient_config or self.m.gclient.c 93 cfg = gclient_config or self.m.gclient.c
98 assert cfg is not None, ( 94 assert cfg is not None, (
99 'missing gclient_config or forgot api.gclient.set_config(...) before?') 95 'missing gclient_config or forgot api.gclient.set_config(...) before?')
100 96
101 # Used by bot_update to determine if we want to run or not.
102 master = self._mastername
103 builder = self._buildername
104 slave = self._slavename
105
106 # Construct our bot_update command. This basically be inclusive of 97 # Construct our bot_update command. This basically be inclusive of
107 # everything required for bot_update to know: 98 # everything required for bot_update to know:
108 root = patch_root 99 root = patch_root
109 if root is None: 100 if root is None:
110 root = self.m.gclient.calculate_patch_root( 101 root = self.m.gclient.calculate_patch_root(
111 self.m.properties.get('patch_project'), cfg) 102 self.m.properties.get('patch_project'), cfg)
112 103
113 if patch: 104 if patch:
114 issue = issue or self._issue 105 issue = issue or self._issue
115 patchset = patchset or self._patchset 106 patchset = patchset or self._patchset
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 146
156 # Allow patch_project's revision if necessary. 147 # Allow patch_project's revision if necessary.
157 # This is important for projects which are checked out as DEPS of the 148 # This is important for projects which are checked out as DEPS of the
158 # gclient solution. 149 # gclient solution.
159 self.m.gclient.set_patch_project_revision( 150 self.m.gclient.set_patch_project_revision(
160 self.m.properties.get('patch_project'), cfg) 151 self.m.properties.get('patch_project'), cfg)
161 152
162 rev_map = cfg.got_revision_mapping.as_jsonish() 153 rev_map = cfg.got_revision_mapping.as_jsonish()
163 154
164 flags = [ 155 flags = [
165 # 1. Do we want to run? (master/builder/slave). 156 # What do we want to check out (spec/root/rev/rev_map).
166 ['--master', master],
167 ['--builder', builder],
168 ['--slave', slave],
169
170 # 2. What do we want to check out (spec/root/rev/rev_map).
171 ['--spec', self.m.gclient.config_to_pythonish(cfg)], 157 ['--spec', self.m.gclient.config_to_pythonish(cfg)],
172 ['--root', root], 158 ['--root', root],
173 ['--revision_mapping_file', self.m.json.input(rev_map)], 159 ['--revision_mapping_file', self.m.json.input(rev_map)],
174 ['--git-cache-dir', cfg.cache_dir], 160 ['--git-cache-dir', cfg.cache_dir],
175 161
176 # 3. How to find the patch, if any (issue/patchset/patch_url). 162 # How to find the patch, if any (issue/patchset/patch_url).
177 ['--issue', issue], 163 ['--issue', issue],
178 ['--patchset', patchset], 164 ['--patchset', patchset],
179 ['--patch_url', patch_url], 165 ['--patch_url', patch_url],
180 ['--rietveld_server', rietveld or self._rietveld], 166 ['--rietveld_server', rietveld or self._rietveld],
181 ['--gerrit_repo', gerrit_repo], 167 ['--gerrit_repo', gerrit_repo],
182 ['--gerrit_ref', gerrit_ref], 168 ['--gerrit_ref', gerrit_ref],
183 ['--apply_issue_email_file', email_file], 169 ['--apply_issue_email_file', email_file],
184 ['--apply_issue_key_file', key_file], 170 ['--apply_issue_key_file', key_file],
185 171
186 # 4. Hookups to JSON output back into recipes. 172 # JSON output back into recipes.
187 ['--output_json', self.m.json.output()],] 173 ['--output_json', self.m.json.output()],]
188 174
189 175
190 # Collect all fixed revisions to simulate them in the json output. 176 # Collect all fixed revisions to simulate them in the json output.
191 # Fixed revision are the explicit input revisions of bot_update.py, i.e. 177 # Fixed revision are the explicit input revisions of bot_update.py, i.e.
192 # every command line parameter "--revision name@value". 178 # every command line parameter "--revision name@value".
193 fixed_revisions = {} 179 fixed_revisions = {}
194 180
195 revisions = {} 181 revisions = {}
196 for solution in cfg.solutions: 182 for solution in cfg.solutions:
(...skipping 19 matching lines...) Expand all
216 # Add extra fetch refspecs. 202 # Add extra fetch refspecs.
217 for ref in refs: 203 for ref in refs:
218 flags.append(['--refs', ref]) 204 flags.append(['--refs', ref])
219 205
220 # Filter out flags that are None. 206 # Filter out flags that are None.
221 cmd = [item for flag_set in flags 207 cmd = [item for flag_set in flags
222 for item in flag_set if flag_set[1] is not None] 208 for item in flag_set if flag_set[1] is not None]
223 209
224 if clobber: 210 if clobber:
225 cmd.append('--clobber') 211 cmd.append('--clobber')
226 if force:
227 cmd.append('--force')
228 if no_shallow: 212 if no_shallow:
229 cmd.append('--no_shallow') 213 cmd.append('--no_shallow')
230 if output_manifest: 214 if output_manifest:
231 cmd.append('--output_manifest') 215 cmd.append('--output_manifest')
232 if with_branch_heads or cfg.with_branch_heads: 216 if with_branch_heads or cfg.with_branch_heads:
233 cmd.append('--with_branch_heads') 217 cmd.append('--with_branch_heads')
234 if gerrit_no_reset: 218 if gerrit_no_reset:
235 cmd.append('--gerrit_no_reset') 219 cmd.append('--gerrit_no_reset')
236 if gerrit_no_rebase_patch_ref or not gerrit_rebase_patch_ref: 220 if gerrit_no_rebase_patch_ref or not gerrit_rebase_patch_ref:
237 cmd.append('--gerrit_no_rebase_patch_ref') 221 cmd.append('--gerrit_no_rebase_patch_ref')
238 222
239 # Inject Json output for testing. 223 # Inject Json output for testing.
240 first_sln = cfg.solutions[0].name 224 first_sln = cfg.solutions[0].name
241 step_test_data = lambda: self.test_api.output_json( 225 step_test_data = lambda: self.test_api.output_json(
242 master, builder, slave, root, first_sln, rev_map, force, 226 root, first_sln, rev_map, self._fail_patch,
243 self._fail_patch,
244 output_manifest=output_manifest, fixed_revisions=fixed_revisions) 227 output_manifest=output_manifest, fixed_revisions=fixed_revisions)
245 228
246 # Add suffixes to the step name, if specified. 229 # Add suffixes to the step name, if specified.
247 name = 'bot_update' 230 name = 'bot_update'
248 if not patch: 231 if not patch:
249 name += ' (without patch)' 232 name += ' (without patch)'
250 if suffix: 233 if suffix:
251 name += ' - %s' % suffix 234 name += ' - %s' % suffix
252 235
253 # Ah hah! Now that everything is in place, lets run bot_update! 236 # Ah hah! Now that everything is in place, lets run bot_update!
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 291
309 # bot_update actually just sets root to be the folder name of the 292 # bot_update actually just sets root to be the folder name of the
310 # first solution. 293 # first solution.
311 if step_result.json.output['did_run']: 294 if step_result.json.output['did_run']:
312 co_root = step_result.json.output['root'] 295 co_root = step_result.json.output['root']
313 cwd = kwargs.get('cwd', self.m.path['slave_build']) 296 cwd = kwargs.get('cwd', self.m.path['slave_build'])
314 if 'checkout' not in self.m.path: 297 if 'checkout' not in self.m.path:
315 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) 298 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep))
316 299
317 return step_result 300 return step_result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698