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

Side by Side Diff: scripts/slave/recipes/findit/chromium/compile.py

Issue 1615963005: [Findit] Refactoring compile recipe return results into report dict instead of list (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build@master
Patch Set: Fixing variable names 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
« no previous file with comments | « no previous file | scripts/slave/recipes/findit/chromium/compile.expected/compile_affected_targets_only.json » ('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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 import json 5 import json
6 6
7 from recipe_engine.config import List 7 from recipe_engine.config import List
8 from recipe_engine.config import Single 8 from recipe_engine.config import Single
9 from recipe_engine.recipe_api import Property 9 from recipe_engine.recipe_api import Property
10 10
11 11
12 DEPS = [ 12 DEPS = [
13 'chromium', 13 'chromium',
14 'chromium_tests', 14 'chromium_tests',
15 'findit', 15 'findit',
16 'gclient', 16 'gclient',
17 'recipe_engine/json', 17 'recipe_engine/json',
18 'recipe_engine/path', 18 'recipe_engine/path',
19 'recipe_engine/properties', 19 'recipe_engine/properties',
20 'recipe_engine/python', 20 'recipe_engine/python',
21 'recipe_engine/step', 21 'recipe_engine/step',
22 ] 22 ]
23 23
24 24
25 PROPERTIES = { 25 PROPERTIES = {
26 'target_mastername': Property( 26 'target_mastername': Property(
27 kind=str, help='The target master to match compile config to.'), 27 kind=str, help='The target master to match compile config to.'),
28 'target_buildername': Property( 28 'target_buildername': Property(
29 kind=str, help='The target builder to match compile config to.'), 29 kind=str, help='The target builder to match compile config to.'),
30 'good_revision': Property( 30 'good_revision': Property(
31 kind=str, help='The last known good chromium revision.'), 31 kind=str, help='The last known good chromium revision.'),
(...skipping 13 matching lines...) Expand all
45 PASSED = 'passed' # Compile passed. 45 PASSED = 'passed' # Compile passed.
46 FAILED = 'failed' # Compile failed. 46 FAILED = 'failed' # Compile failed.
47 47
48 48
49 def _run_compile_at_revision(api, target_mastername, target_buildername, 49 def _run_compile_at_revision(api, target_mastername, target_buildername,
50 revision, compile_targets, use_analyze): 50 revision, compile_targets, use_analyze):
51 with api.step.nest('test %s' % str(revision)): 51 with api.step.nest('test %s' % str(revision)):
52 # Checkout code at the given revision to recompile. 52 # Checkout code at the given revision to recompile.
53 bot_config = api.chromium_tests.create_bot_config_object( 53 bot_config = api.chromium_tests.create_bot_config_object(
54 target_mastername, target_buildername) 54 target_mastername, target_buildername)
55 bot_update_step, bot_db = \ 55 bot_update_step, bot_db = api.chromium_tests.prepare_checkout(
56 api.chromium_tests.prepare_checkout( 56 bot_config, root_solution_revision=revision)
57 bot_config,
58 root_solution_revision=revision)
59 57
60 # TODO(http://crbug.com/560991): if compile targets are provided, check 58 # TODO(http://crbug.com/560991): if compile targets are provided, check
61 # whether they exist and then use analyze to compile the impacted ones by 59 # whether they exist and then use analyze to compile the impacted ones by
62 # the given revision. 60 # the given revision.
63 compile_targets = sorted(set(compile_targets or [])) 61 compile_targets = sorted(set(compile_targets or []))
64 if not compile_targets: 62 if not compile_targets:
65 _, tests_including_triggered = api.chromium_tests.get_tests( 63 _, tests_including_triggered = api.chromium_tests.get_tests(
66 bot_config, bot_db) 64 bot_config, bot_db)
67 compile_targets = api.chromium_tests.get_compile_targets( 65 compile_targets = api.chromium_tests.get_compile_targets(
68 bot_config, bot_db, tests_including_triggered) 66 bot_config, bot_db, tests_including_triggered)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 target_mastername, target_buildername) 105 target_mastername, target_buildername)
108 api.chromium_tests.configure_build( 106 api.chromium_tests.configure_build(
109 bot_config, override_bot_type='builder_tester') 107 bot_config, override_bot_type='builder_tester')
110 108
111 # Sync to bad revision, and retrieve revisions in the regression range. 109 # Sync to bad revision, and retrieve revisions in the regression range.
112 api.chromium_tests.prepare_checkout( 110 api.chromium_tests.prepare_checkout(
113 bot_config, 111 bot_config,
114 root_solution_revision=bad_revision) 112 root_solution_revision=bad_revision)
115 revisions_to_check = api.findit.revisions_between(good_revision, bad_revision) 113 revisions_to_check = api.findit.revisions_between(good_revision, bad_revision)
116 114
117 results = [] 115 compile_results = {}
116 try_job_metadata = {
117 'number_of_commits_in_range': len(revisions_to_check)
stgao 2016/01/29 02:15:52 'regression_range_size' instead?
lijeffrey 2016/01/29 09:53:42 Done.
118 }
119 report = {
120 'result': compile_results,
121 'metadata': try_job_metadata,
122 }
123
124 last_result = None
118 try: 125 try:
119 for current_revision in revisions_to_check: 126 for current_revision in revisions_to_check:
120 compile_result = _run_compile_at_revision( 127 compile_result = _run_compile_at_revision(
121 api, target_mastername, target_buildername, 128 api, target_mastername, target_buildername,
122 current_revision, requested_compile_targets, use_analyze) 129 current_revision, requested_compile_targets, use_analyze)
123 130
124 results.append([current_revision, compile_result]) 131 compile_results[current_revision] = compile_result
132 last_revision = current_revision
133 last_result = compile_result
stgao 2016/01/29 02:15:52 There seems a bug (not an obvious one): when testi
lijeffrey 2016/01/29 09:53:42 Done.
125 if compile_result == CompileResult.FAILED: 134 if compile_result == CompileResult.FAILED:
126 # TODO(http://crbug.com/560991): if compile targets are specified, 135 # TODO(http://crbug.com/560991): if compile targets are specified,
127 # compile may fail because those targets are added in a later revision. 136 # compile may fail because those targets are added in a later revision.
128 break # Found the culprit, no need to check later revisions. 137 break # Found the culprit, no need to check later revisions.
129 finally: 138 finally:
130 # Report the result. 139 # Report the result.
131 # TODO(http://crbug.com/563807): use api.python.succeeding_step instead. 140 # TODO(http://crbug.com/563807): use api.python.succeeding_step instead.
132 step_result = api.python.inline( 141 step_result = api.python.inline(
133 'report', 'import sys; sys.exit(0)', add_python_log=False) 142 'report', 'import sys; sys.exit(0)', add_python_log=False)
134 if (not requested_compile_targets and 143 if (not requested_compile_targets and
135 results and results[-1][1] == CompileResult.FAILED): 144 compile_results and last_result == CompileResult.FAILED):
136 step_result.presentation.step_text = '<br/>Culprit: %s' % results[-1][0] 145 step_result.presentation.step_text = (
146 '<br/>Culprit: %s' % compile_results[last_revision])
stgao 2016/01/29 02:15:52 Shouldn't it be last_revision instead? And it coul
lijeffrey 2016/01/29 09:53:42 Done.
137 step_result.presentation.logs.setdefault('result', []).append( 147 step_result.presentation.logs.setdefault('result', []).append(
138 json.dumps(results, indent=2)) 148 json.dumps(report, indent=2))
139 149
140 # Set the result as a build property too, so that it will be reported back 150 # Set the result as a build property too, so that it will be reported back
141 # to Buildbucket and Findit will pull from there instead of buildbot master. 151 # to Buildbucket and Findit will pull from there instead of buildbot master.
142 step_result.presentation.properties['result'] = results 152 step_result.presentation.properties['result'] = report
143 153
144 return results 154 return compile_results
stgao 2016/01/29 02:15:52 Let's return the ``report`` instead. To be consist
lijeffrey 2016/01/29 09:53:42 Done.
145 155
146 156
147 def GenTests(api): 157 def GenTests(api):
148 def props(compile_targets=None, use_analyze=False): 158 def props(compile_targets=None, use_analyze=False):
149 properties = { 159 properties = {
150 'mastername': 'tryserver.chromium.linux', 160 'mastername': 'tryserver.chromium.linux',
151 'buildername': 'linux_variable', 161 'buildername': 'linux_variable',
152 'slavename': 'build1-a1', 162 'slavename': 'build1-a1',
153 'buildnumber': '1', 163 'buildnumber': '1',
154 'target_mastername': 'chromium.linux', 164 'target_mastername': 'chromium.linux',
155 'target_buildername': 'Linux Builder', 165 'target_buildername': 'Linux Builder',
156 'good_revision': 'r0', 166 'good_revision': 'r0',
157 'bad_revision': 'r1', 167 'bad_revision': 'r1',
158 'use_analyze': use_analyze, 168 'use_analyze': use_analyze,
159 } 169 }
160 if compile_targets: 170 if compile_targets:
161 properties['compile_targets'] = compile_targets 171 properties['compile_targets'] = compile_targets
162 return api.properties(**properties) 172 return api.properties(**properties)
163 173
164 yield ( 174 yield (
165 api.test('compile_specified_targets') + 175 api.test('compile_specified_targets') +
166 props(compile_targets=['target_name']) 176 props(compile_targets=['target_name'])
167 ) 177 )
168 178
169 yield ( 179 yield (
170 api.test('compile_default_targets') + 180 api.test('compile_default_targets') +
171 props() + 181 props() +
172 api.override_step_data('test r1.read test spec', 182 api.override_step_data('test r1.read test spec',
173 api.json.output({ 183 api.json.output({
174 'Linux Builder': { 184 'Linux Builder': {
175 'additional_compile_targets': [ 185 'additional_compile_targets': [
176 'base_unittests', 186 'base_unittests',
177 ], 187 ],
178 } 188 }
179 })) 189 }))
180 ) 190 )
181 191
182 yield ( 192 yield (
183 api.test('compile_succeeded') + 193 api.test('compile_succeeded') +
184 props() + 194 props() +
185 api.override_step_data('test r1.compile', retcode=1) 195 api.override_step_data('test r1.compile', retcode=1)
186 ) 196 )
187 197
188 yield ( 198 yield (
(...skipping 30 matching lines...) Expand all
219 'test_targets': [], 229 'test_targets': [],
220 }) 230 })
221 ) 231 )
222 ) 232 )
223 233
224 yield ( 234 yield (
225 api.test('compile_affected_targets_only') + 235 api.test('compile_affected_targets_only') +
226 props(use_analyze=True) + 236 props(use_analyze=True) +
227 api.override_step_data('test r1.read test spec', 237 api.override_step_data('test r1.read test spec',
228 api.json.output({ 238 api.json.output({
229 'Linux Builder': { 239 'Linux Builder': {
230 'additional_compile_targets': [ 240 'additional_compile_targets': [
231 'a', 'a_run', 241 'a', 'a_run',
232 'b', 'b_run', 242 'b', 'b_run',
233 ], 243 ],
234 } 244 }
235 })) + 245 })) +
236 api.override_step_data( 246 api.override_step_data(
237 'test r1.analyze', 247 'test r1.analyze',
238 api.json.output({ 248 api.json.output({
239 'status': 'Found dependency', 249 'status': 'Found dependency',
240 'compile_targets': ['a', 'a_run'], 250 'compile_targets': ['a', 'a_run'],
241 'test_targets': ['a', 'a_run'], 251 'test_targets': ['a', 'a_run'],
242 }) 252 })
243 ) 253 )
244 ) 254 )
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipes/findit/chromium/compile.expected/compile_affected_targets_only.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698