OLD | NEW |
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 |
(...skipping 14 matching lines...) Expand all Loading... |
48 kwargs['env']['PATH'] = self.m.path.pathsep.join([ | 48 kwargs['env']['PATH'] = self.m.path.pathsep.join([ |
49 kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) | 49 kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) |
50 return self.m.python(name, bot_update_path, cmd, **kwargs) | 50 return self.m.python(name, bot_update_path, cmd, **kwargs) |
51 | 51 |
52 @property | 52 @property |
53 def last_returned_properties(self): | 53 def last_returned_properties(self): |
54 return self._last_returned_properties | 54 return self._last_returned_properties |
55 | 55 |
56 def ensure_checkout(self, gclient_config=None, suffix=None, | 56 def ensure_checkout(self, gclient_config=None, suffix=None, |
57 patch=True, update_presentation=True, | 57 patch=True, update_presentation=True, |
58 force=False, patch_root=None, no_shallow=False, | 58 patch_root=None, no_shallow=False, |
59 with_branch_heads=False, refs=None, | 59 with_branch_heads=False, refs=None, |
60 patch_oauth2=False, | 60 patch_oauth2=False, |
61 output_manifest=True, clobber=False, | 61 output_manifest=True, clobber=False, |
62 root_solution_revision=None, rietveld=None, issue=None, | 62 root_solution_revision=None, rietveld=None, issue=None, |
63 patchset=None, gerrit_no_reset=False, **kwargs): | 63 patchset=None, gerrit_no_reset=False, **kwargs): |
64 """ | 64 """ |
65 Args: | 65 Args: |
66 gclient_config: The gclient configuration to use when running bot_update. | 66 gclient_config: The gclient configuration to use when running bot_update. |
67 If omitted, the current gclient configuration is used. | 67 If omitted, the current gclient configuration is used. |
68 rietveld: The rietveld server to use. If omitted, will infer from | 68 rietveld: The rietveld server to use. If omitted, will infer from |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 # Allow patch_project's revision if necessary. | 129 # Allow patch_project's revision if necessary. |
130 # This is important for projects which are checked out as DEPS of the | 130 # This is important for projects which are checked out as DEPS of the |
131 # gclient solution. | 131 # gclient solution. |
132 self.m.gclient.set_patch_project_revision( | 132 self.m.gclient.set_patch_project_revision( |
133 self.m.properties.get('patch_project'), cfg) | 133 self.m.properties.get('patch_project'), cfg) |
134 | 134 |
135 rev_map = cfg.got_revision_mapping.as_jsonish() | 135 rev_map = cfg.got_revision_mapping.as_jsonish() |
136 | 136 |
137 flags = [ | 137 flags = [ |
138 # 1. Do we want to run? (master/builder/slave). | 138 # 1. What do we want to check out (spec/root/rev/rev_map). |
139 ['--master', master], | |
140 ['--builder', builder], | |
141 ['--slave', slave], | |
142 | |
143 # 2. What do we want to check out (spec/root/rev/rev_map). | |
144 ['--spec', self.m.gclient.config_to_pythonish(cfg)], | 139 ['--spec', self.m.gclient.config_to_pythonish(cfg)], |
145 ['--root', root], | 140 ['--root', root], |
146 ['--revision_mapping_file', self.m.json.input(rev_map)], | 141 ['--revision_mapping_file', self.m.json.input(rev_map)], |
147 ['--git-cache-dir', cfg.cache_dir], | 142 ['--git-cache-dir', cfg.cache_dir], |
148 | 143 |
149 # 3. How to find the patch, if any (issue/patchset/patch_url). | 144 # 2. How to find the patch, if any (issue/patchset/patch_url). |
150 ['--issue', issue], | 145 ['--issue', issue], |
151 ['--patchset', patchset], | 146 ['--patchset', patchset], |
152 ['--patch_url', patch_url], | 147 ['--patch_url', patch_url], |
153 ['--rietveld_server', rietveld or self._rietveld], | 148 ['--rietveld_server', rietveld or self._rietveld], |
154 ['--gerrit_repo', gerrit_repo], | 149 ['--gerrit_repo', gerrit_repo], |
155 ['--gerrit_ref', gerrit_ref], | 150 ['--gerrit_ref', gerrit_ref], |
156 ['--apply_issue_email_file', email_file], | 151 ['--apply_issue_email_file', email_file], |
157 ['--apply_issue_key_file', key_file], | 152 ['--apply_issue_key_file', key_file], |
158 | 153 |
159 # 4. Hookups to JSON output back into recipes. | 154 # 3. Hookups to JSON output back into recipes. |
160 ['--output_json', self.m.json.output()],] | 155 ['--output_json', self.m.json.output()],] |
161 | 156 |
162 | 157 |
163 # Collect all fixed revisions to simulate them in the json output. | 158 # 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. | 159 # Fixed revision are the explicit input revisions of bot_update.py, i.e. |
165 # every command line parameter "--revision name@value". | 160 # every command line parameter "--revision name@value". |
166 fixed_revisions = {} | 161 fixed_revisions = {} |
167 | 162 |
168 revisions = {} | 163 revisions = {} |
169 for solution in cfg.solutions: | 164 for solution in cfg.solutions: |
(...skipping 19 matching lines...) Expand all Loading... |
189 # Add extra fetch refspecs. | 184 # Add extra fetch refspecs. |
190 for ref in refs: | 185 for ref in refs: |
191 flags.append(['--refs', ref]) | 186 flags.append(['--refs', ref]) |
192 | 187 |
193 # Filter out flags that are None. | 188 # Filter out flags that are None. |
194 cmd = [item for flag_set in flags | 189 cmd = [item for flag_set in flags |
195 for item in flag_set if flag_set[1] is not None] | 190 for item in flag_set if flag_set[1] is not None] |
196 | 191 |
197 if clobber: | 192 if clobber: |
198 cmd.append('--clobber') | 193 cmd.append('--clobber') |
199 if force: | |
200 cmd.append('--force') | |
201 if no_shallow: | 194 if no_shallow: |
202 cmd.append('--no_shallow') | 195 cmd.append('--no_shallow') |
203 if output_manifest: | 196 if output_manifest: |
204 cmd.append('--output_manifest') | 197 cmd.append('--output_manifest') |
205 if with_branch_heads or cfg.with_branch_heads: | 198 if with_branch_heads or cfg.with_branch_heads: |
206 cmd.append('--with_branch_heads') | 199 cmd.append('--with_branch_heads') |
207 if gerrit_no_reset: | 200 if gerrit_no_reset: |
208 cmd.append('--gerrit_no_reset') | 201 cmd.append('--gerrit_no_reset') |
209 | 202 |
210 # Inject Json output for testing. | 203 # Inject Json output for testing. |
211 git_mode = self._mastername not in SVN_MASTERS | 204 git_mode = self._mastername not in SVN_MASTERS |
212 first_sln = cfg.solutions[0].name | 205 first_sln = cfg.solutions[0].name |
213 step_test_data = lambda: self.test_api.output_json( | 206 step_test_data = lambda: self.test_api.output_json( |
214 master, builder, slave, root, first_sln, rev_map, git_mode, force, | 207 master, builder, slave, root, first_sln, rev_map, git_mode, |
215 self._fail_patch, | 208 self._fail_patch, |
216 output_manifest=output_manifest, fixed_revisions=fixed_revisions) | 209 output_manifest=output_manifest, fixed_revisions=fixed_revisions) |
217 | 210 |
218 # Add suffixes to the step name, if specified. | 211 # Add suffixes to the step name, if specified. |
219 name = 'bot_update' | 212 name = 'bot_update' |
220 if not patch: | 213 if not patch: |
221 name += ' (without patch)' | 214 name += ' (without patch)' |
222 if suffix: | 215 if suffix: |
223 name += ' - %s' % suffix | 216 name += ' - %s' % suffix |
224 | 217 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 267 |
275 # bot_update actually just sets root to be the folder name of the | 268 # bot_update actually just sets root to be the folder name of the |
276 # first solution. | 269 # first solution. |
277 if step_result.json.output['did_run']: | 270 if step_result.json.output['did_run']: |
278 co_root = step_result.json.output['root'] | 271 co_root = step_result.json.output['root'] |
279 cwd = kwargs.get('cwd', self.m.path['slave_build']) | 272 cwd = kwargs.get('cwd', self.m.path['slave_build']) |
280 if 'checkout' not in self.m.path: | 273 if 'checkout' not in self.m.path: |
281 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) | 274 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) |
282 | 275 |
283 return step_result | 276 return step_result |
OLD | NEW |