| OLD | NEW |
| 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 from common import buildbucket_client | 5 from common import buildbucket_client |
| 6 from model.wf_try_job import WfTryJob | 6 from model.wf_try_job import WfTryJob |
| 7 from pipeline_wrapper import BasePipeline | 7 from pipeline_wrapper import BasePipeline |
| 8 from pipeline_wrapper import pipeline | 8 from pipeline_wrapper import pipeline |
| 9 from waterfall import waterfall_config | 9 from waterfall import waterfall_config |
| 10 from waterfall.try_job_type import TryJobType |
| 10 | 11 |
| 11 | 12 |
| 12 class ScheduleTryJobPipeline(BasePipeline): | 13 class ScheduleTryJobPipeline(BasePipeline): |
| 13 """A pipeline for scheduling a new try job for current build.""" | 14 """A pipeline for scheduling a new try job for current build.""" |
| 14 | 15 |
| 15 def _getBuildProperties(self, recipe, master_name, builder_name, | 16 def _GetBuildProperties( |
| 16 good_revision, bad_revision, compile_targets): | 17 self, master_name, builder_name, good_revision, bad_revision, |
| 17 | 18 try_job_type, compile_targets, targeted_tests): |
| 18 properties = { | 19 properties = { |
| 19 'recipe': recipe, | 20 'recipe': 'findit/chromium/%s' % try_job_type, |
| 20 'good_revision': good_revision, | 21 'good_revision': good_revision, |
| 21 'bad_revision': bad_revision, | 22 'bad_revision': bad_revision, |
| 22 'target_mastername': master_name, | 23 'target_mastername': master_name |
| 23 'target_buildername': builder_name | |
| 24 } | 24 } |
| 25 | 25 |
| 26 if compile_targets: | 26 if try_job_type == TryJobType.COMPILE: |
| 27 properties['compile_targets'] = compile_targets | 27 properties['target_buildername'] = builder_name |
| 28 if compile_targets: |
| 29 properties['compile_targets'] = compile_targets |
| 30 else: # try_job_type is 'test'. |
| 31 properties['target_testername'] = builder_name |
| 32 assert targeted_tests |
| 33 properties['tests'] = targeted_tests |
| 28 | 34 |
| 29 return properties | 35 return properties |
| 30 | 36 |
| 31 # Arguments number differs from overridden method - pylint: disable=W0221 | 37 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 32 def run( | 38 def run( |
| 33 self, master_name, builder_name, build_number, | 39 self, master_name, builder_name, build_number, good_revision, |
| 34 good_revision, bad_revision, compile_targets): | 40 bad_revision, try_job_type, compile_targets, targeted_tests): |
| 35 tryserver_mastername, tryserver_buildername = ( | 41 tryserver_mastername, tryserver_buildername = ( |
| 36 waterfall_config.GetTrybotForWaterfallBuilder( | 42 waterfall_config.GetTrybotForWaterfallBuilder( |
| 37 master_name, builder_name)) | 43 master_name, builder_name)) |
| 38 | 44 |
| 39 recipe = 'findit/chromium/compile' | 45 properties = self._GetBuildProperties( |
| 40 properties = self._getBuildProperties( | 46 master_name, builder_name, good_revision, bad_revision, |
| 41 recipe, master_name, builder_name, good_revision, bad_revision, | 47 try_job_type, compile_targets, targeted_tests) |
| 42 compile_targets) | |
| 43 | 48 |
| 44 try_job = buildbucket_client.TryJob( | 49 try_job = buildbucket_client.TryJob( |
| 45 tryserver_mastername, tryserver_buildername, None, properties, []) | 50 tryserver_mastername, tryserver_buildername, None, properties, []) |
| 46 error, build = buildbucket_client.TriggerTryJobs([try_job])[0] | 51 error, build = buildbucket_client.TriggerTryJobs([try_job])[0] |
| 47 | 52 |
| 48 if error: # pragma: no cover | 53 if error: # pragma: no cover |
| 49 raise pipeline.Retry( | 54 raise pipeline.Retry( |
| 50 'Error "%s" occurred. Reason: "%s"' % (error.message, error.reason)) | 55 'Error "%s" occurred. Reason: "%s"' % (error.message, error.reason)) |
| 51 | 56 |
| 52 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) | 57 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) |
| 53 try_job_result.compile_results.append({'try_job_id': build.id}) | 58 if try_job_type == TryJobType.COMPILE: |
| 59 try_job_result.compile_results.append({'try_job_id': build.id}) |
| 60 else: |
| 61 try_job_result.test_results.append({'try_job_id': build.id}) |
| 54 try_job_result.try_job_ids.append(build.id) | 62 try_job_result.try_job_ids.append(build.id) |
| 55 try_job_result.put() | 63 try_job_result.put() |
| 56 | 64 |
| 57 return build.id | 65 return build.id |
| OLD | NEW |