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

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

Issue 1954833002: Add bot_update_lite into recipes (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Remove expired args Created 4 years, 7 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 | « recipe_modules/bot_update/__init__.py ('k') | recipe_modules/bot_update/example.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # This is just for testing, to indicate if a master is using a Git scheduler 11 # This is just for testing, to indicate if a master is using a Git scheduler
12 # or not. 12 # or not.
13 SVN_MASTERS = ( 13 SVN_MASTERS = (
14 'experimental.svn', 14 'experimental.svn',
15 ) 15 )
16 16
17 17
18 class BotUpdateApi(recipe_api.RecipeApi): 18 class BotUpdateApi(recipe_api.RecipeApi):
19 19
20 def __init__(self, mastername, buildername, slavename, issue, patchset, 20 def __init__(self, mastername, buildername, slavename, issue, patchset,
21 patch_url, repository, gerrit_ref, rietveld, revision, 21 patch_url, repository, gerrit_ref, rietveld, revision,
22 parent_got_revision, deps_revision_overrides, fail_patch, 22 parent_got_revision, deps_revision_overrides, fail_patch,
23 *args, **kwargs): 23 lite, *args, **kwargs):
24 self._mastername = mastername 24 self._mastername = mastername
25 self._buildername = buildername 25 self._buildername = buildername
26 self._slavename = slavename 26 self._slavename = slavename
27 self._issue = issue 27 self._issue = issue
28 self._patchset = patchset 28 self._patchset = patchset
29 self._patch_url = patch_url 29 self._patch_url = patch_url
30 self._repository = repository 30 self._repository = repository
31 self._gerrit_ref = gerrit_ref 31 self._gerrit_ref = gerrit_ref
32 self._rietveld = rietveld 32 self._rietveld = rietveld
33 self._revision = revision 33 self._revision = revision
34 self._parent_got_revision = parent_got_revision 34 self._parent_got_revision = parent_got_revision
35 self._deps_revision_overrides = deps_revision_overrides 35 self._deps_revision_overrides = deps_revision_overrides
36 self._fail_patch = fail_patch 36 self._fail_patch = fail_patch
37 self._lite = lite
37 38
38 self._last_returned_properties = {} 39 self._last_returned_properties = {}
39 super(BotUpdateApi, self).__init__(*args, **kwargs) 40 super(BotUpdateApi, self).__init__(*args, **kwargs)
40 41
41 def __call__(self, name, cmd, **kwargs): 42 def __call__(self, name, cmd, **kwargs):
42 """Wrapper for easy calling of bot_update.""" 43 """Wrapper for easy calling of bot_update."""
43 assert isinstance(cmd, (list, tuple)) 44 assert isinstance(cmd, (list, tuple))
44 bot_update_path = self.resource('bot_update.py') 45 bot_update_path = self.resource('bot_update.py')
46 # TODO(hinoka): This should eventually be default.
47 if self._lite:
48 bot_update_path = self.resource('bot_update_lite.py')
45 kwargs.setdefault('infra_step', True) 49 kwargs.setdefault('infra_step', True)
46 kwargs.setdefault('env', {}) 50 kwargs.setdefault('env', {})
47 kwargs['env'].setdefault('PATH', '%(PATH)s') 51 kwargs['env'].setdefault('PATH', '%(PATH)s')
48 kwargs['env']['PATH'] = self.m.path.pathsep.join([ 52 kwargs['env']['PATH'] = self.m.path.pathsep.join([
49 kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) 53 kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)])
50 return self.m.python(name, bot_update_path, cmd, **kwargs) 54 return self.m.python(name, bot_update_path, cmd, **kwargs)
51 55
52 @property 56 @property
53 def last_returned_properties(self): 57 def last_returned_properties(self):
54 return self._last_returned_properties 58 return self._last_returned_properties
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 else: 130 else:
127 email_file = key_file = None 131 email_file = key_file = None
128 132
129 # Allow patch_project's revision if necessary. 133 # Allow patch_project's revision if necessary.
130 # This is important for projects which are checked out as DEPS of the 134 # This is important for projects which are checked out as DEPS of the
131 # gclient solution. 135 # gclient solution.
132 self.m.gclient.set_patch_project_revision( 136 self.m.gclient.set_patch_project_revision(
133 self.m.properties.get('patch_project'), cfg) 137 self.m.properties.get('patch_project'), cfg)
134 138
135 rev_map = cfg.got_revision_mapping.as_jsonish() 139 rev_map = cfg.got_revision_mapping.as_jsonish()
140 flags = []
136 141
137 flags = [ 142 if not self._lite:
hinoka 2016/05/05 20:36:48 This is ordered first on purpose, to avoid a no-op
138 # 1. Do we want to run? (master/builder/slave). 143 # 1. Do we want to run? (master/builder/slave).
139 ['--master', master], 144 flags.extend([
140 ['--builder', builder], 145 ['--master', master],
141 ['--slave', slave], 146 ['--builder', builder],
147 ['--slave', slave],
148 ])
142 149
150 flags.extend([
143 # 2. What do we want to check out (spec/root/rev/rev_map). 151 # 2. What do we want to check out (spec/root/rev/rev_map).
144 ['--spec', self.m.gclient.config_to_pythonish(cfg)], 152 ['--spec', self.m.gclient.config_to_pythonish(cfg)],
145 ['--root', root], 153 ['--root', root],
146 ['--revision_mapping_file', self.m.json.input(rev_map)], 154 ['--revision_mapping_file', self.m.json.input(rev_map)],
147 ['--git-cache-dir', cfg.cache_dir], 155 ['--git-cache-dir', cfg.cache_dir],
148 156
149 # 3. How to find the patch, if any (issue/patchset/patch_url). 157 # 3. How to find the patch, if any (issue/patchset/patch_url).
150 ['--issue', issue], 158 ['--issue', issue],
151 ['--patchset', patchset], 159 ['--patchset', patchset],
152 ['--patch_url', patch_url], 160 ['--patch_url', patch_url],
153 ['--rietveld_server', rietveld or self._rietveld], 161 ['--rietveld_server', rietveld or self._rietveld],
154 ['--gerrit_repo', gerrit_repo], 162 ['--gerrit_repo', gerrit_repo],
155 ['--gerrit_ref', gerrit_ref], 163 ['--gerrit_ref', gerrit_ref],
156 ['--apply_issue_email_file', email_file], 164 ['--apply_issue_email_file', email_file],
157 ['--apply_issue_key_file', key_file], 165 ['--apply_issue_key_file', key_file],
158 166
159 # 4. Hookups to JSON output back into recipes. 167 # 4. Hookups to JSON output back into recipes.
160 ['--output_json', self.m.json.output()],] 168 ['--output_json', self.m.json.output()],])
169
170
161 171
162 172
163 # Collect all fixed revisions to simulate them in the json output. 173 # Collect all fixed revisions to simulate them in the json output.
164 # Fixed revision are the explicit input revisions of bot_update.py, i.e. 174 # Fixed revision are the explicit input revisions of bot_update.py, i.e.
165 # every command line parameter "--revision name@value". 175 # every command line parameter "--revision name@value".
166 fixed_revisions = {} 176 fixed_revisions = {}
167 177
168 revisions = {} 178 revisions = {}
169 for solution in cfg.solutions: 179 for solution in cfg.solutions:
170 if solution.revision: 180 if solution.revision:
(...skipping 18 matching lines...) Expand all
189 # Add extra fetch refspecs. 199 # Add extra fetch refspecs.
190 for ref in refs: 200 for ref in refs:
191 flags.append(['--refs', ref]) 201 flags.append(['--refs', ref])
192 202
193 # Filter out flags that are None. 203 # Filter out flags that are None.
194 cmd = [item for flag_set in flags 204 cmd = [item for flag_set in flags
195 for item in flag_set if flag_set[1] is not None] 205 for item in flag_set if flag_set[1] is not None]
196 206
197 if clobber: 207 if clobber:
198 cmd.append('--clobber') 208 cmd.append('--clobber')
199 if force: 209 if force and not self._lite:
200 cmd.append('--force') 210 cmd.append('--force')
201 if no_shallow: 211 if no_shallow:
202 cmd.append('--no_shallow') 212 cmd.append('--no_shallow')
203 if output_manifest: 213 if output_manifest:
204 cmd.append('--output_manifest') 214 cmd.append('--output_manifest')
205 if with_branch_heads or cfg.with_branch_heads: 215 if with_branch_heads or cfg.with_branch_heads:
206 cmd.append('--with_branch_heads') 216 cmd.append('--with_branch_heads')
207 if gerrit_no_reset: 217 if gerrit_no_reset:
208 cmd.append('--gerrit_no_reset') 218 cmd.append('--gerrit_no_reset')
209 219
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 284
275 # bot_update actually just sets root to be the folder name of the 285 # bot_update actually just sets root to be the folder name of the
276 # first solution. 286 # first solution.
277 if step_result.json.output['did_run']: 287 if step_result.json.output['did_run']:
278 co_root = step_result.json.output['root'] 288 co_root = step_result.json.output['root']
279 cwd = kwargs.get('cwd', self.m.path['slave_build']) 289 cwd = kwargs.get('cwd', self.m.path['slave_build'])
280 if 'checkout' not in self.m.path: 290 if 'checkout' not in self.m.path:
281 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) 291 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep))
282 292
283 return step_result 293 return step_result
OLDNEW
« no previous file with comments | « recipe_modules/bot_update/__init__.py ('k') | recipe_modules/bot_update/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698