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

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

Issue 476503002: Re-land r289084 - "Make telemetry*_unittests upload to test-results.appspot.com" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: tweak how we set bot_update.properties Created 6 years, 4 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
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium/__init__.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 8
9 from slave import recipe_api 9 from slave import recipe_api
10 from slave import recipe_util 10 from slave import recipe_util
(...skipping 30 matching lines...) Expand all
41 ret += ']' 41 ret += ']'
42 elif isinstance(spec, basestring): 42 elif isinstance(spec, basestring):
43 ret = repr(str(spec)) 43 ret = repr(str(spec))
44 else: 44 else:
45 ret = repr(spec) 45 ret = repr(spec)
46 return ret 46 return ret
47 47
48 48
49 class BotUpdateApi(recipe_api.RecipeApi): 49 class BotUpdateApi(recipe_api.RecipeApi):
50 50
51 def __init__(self, *args, **kwargs):
52 self._properties = {}
53 super(BotUpdateApi, self).__init__(*args, **kwargs)
54
51 def __call__(self, name, cmd, **kwargs): 55 def __call__(self, name, cmd, **kwargs):
52 """Wrapper for easy calling of bot_update.""" 56 """Wrapper for easy calling of bot_update."""
53 assert isinstance(cmd, (list, tuple)) 57 assert isinstance(cmd, (list, tuple))
54 bot_update_path = self.m.path['build'].join( 58 bot_update_path = self.m.path['build'].join(
55 'scripts', 'slave', 'bot_update.py') 59 'scripts', 'slave', 'bot_update.py')
56 return self.m.python(name, bot_update_path, cmd, **kwargs) 60 return self.m.python(name, bot_update_path, cmd, **kwargs)
57 61
62 @property
63 def properties(self):
64 return self._properties
65
58 def ensure_checkout(self, gclient_config=None, suffix=None, 66 def ensure_checkout(self, gclient_config=None, suffix=None,
59 patch=True, update_presentation=True, 67 patch=True, update_presentation=True,
60 force=False, patch_root=None, no_shallow=False, 68 force=False, patch_root=None, no_shallow=False,
61 **kwargs): 69 **kwargs):
62 # We can re-use the gclient spec from the gclient module, since all the 70 # We can re-use the gclient spec from the gclient module, since all the
63 # data bot_update needs is already configured into the gclient spec. 71 # data bot_update needs is already configured into the gclient spec.
64 cfg = gclient_config or self.m.gclient.c 72 cfg = gclient_config or self.m.gclient.c
65 spec_string = jsonish_to_python(cfg.as_jsonish(), True) 73 spec_string = jsonish_to_python(cfg.as_jsonish(), True)
66 74
67 # Used by bot_update to determine if we want to run or not. 75 # Used by bot_update to determine if we want to run or not.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 name += ' (without patch)' 159 name += ' (without patch)'
152 if suffix: 160 if suffix:
153 name += ' - %s' % suffix 161 name += ' - %s' % suffix
154 162
155 # Ah hah! Now that everything is in place, lets run bot_update! 163 # Ah hah! Now that everything is in place, lets run bot_update!
156 try: 164 try:
157 self(name, cmd, step_test_data=step_test_data, **kwargs) 165 self(name, cmd, step_test_data=step_test_data, **kwargs)
158 finally: 166 finally:
159 step_result = self.m.step.active_result 167 step_result = self.m.step.active_result
160 168
169 self._properties = step_result.json.output.get('properties', {})
170
161 if update_presentation: 171 if update_presentation:
162 # Set properties such as got_revision. 172 # Set properties such as got_revision.
163 if 'properties' in step_result.json.output: 173 for prop_name, prop_value in self.properties.iteritems():
164 properties = step_result.json.output['properties'] 174 step_result.presentation.properties[prop_name] = prop_value
165 for prop_name, prop_value in properties.iteritems():
166 step_result.presentation.properties[prop_name] = prop_value
167 # Add helpful step description in the step UI. 175 # Add helpful step description in the step UI.
168 if 'step_text' in step_result.json.output: 176 if 'step_text' in step_result.json.output:
169 step_text = step_result.json.output['step_text'] 177 step_text = step_result.json.output['step_text']
170 step_result.presentation.step_text = step_text 178 step_result.presentation.step_text = step_text
171 # Add log line output. 179 # Add log line output.
172 if 'log_lines' in step_result.json.output: 180 if 'log_lines' in step_result.json.output:
173 for log_name, log_lines in step_result.json.output['log_lines']: 181 for log_name, log_lines in step_result.json.output['log_lines']:
174 step_result.presentation.logs[log_name] = log_lines.splitlines() 182 step_result.presentation.logs[log_name] = log_lines.splitlines()
175 # Abort the build on failure, if its not a patch failure. 183 # Abort the build on failure, if its not a patch failure.
176 if step_result.presentation.status == self.m.step.FAILURE: 184 if step_result.presentation.status == self.m.step.FAILURE:
(...skipping 17 matching lines...) Expand all
194 step_test_data=self.test_api.patch_error_data) 202 step_test_data=self.test_api.patch_error_data)
195 203
196 # bot_update actually just sets root to be the folder name of the 204 # bot_update actually just sets root to be the folder name of the
197 # first solution. 205 # first solution.
198 if step_result.json.output['did_run']: 206 if step_result.json.output['did_run']:
199 co_root = step_result.json.output['root'] 207 co_root = step_result.json.output['root']
200 cwd = kwargs.get('cwd', self.m.path['slave_build']) 208 cwd = kwargs.get('cwd', self.m.path['slave_build'])
201 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) 209 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep))
202 210
203 return step_result 211 return step_result
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698