| 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.pipeline_wrapper import BasePipeline | 5 from common.pipeline_wrapper import BasePipeline |
| 6 from common.pipeline_wrapper import pipeline | 6 from common.pipeline_wrapper import pipeline |
| 7 from common.waterfall import buildbucket_client | 7 from common.waterfall import buildbucket_client |
| 8 from model.wf_try_job import WfTryJob | 8 from model.wf_try_job import WfTryJob |
| 9 from model.wf_try_job_data import WfTryJobData | 9 from model.wf_try_job_data import WfTryJobData |
| 10 from waterfall import buildbot | 10 from waterfall import buildbot |
| 11 from waterfall import waterfall_config | 11 from waterfall import waterfall_config |
| 12 from waterfall.try_job_type import TryJobType | 12 from waterfall.try_job_type import TryJobType |
| 13 | 13 |
| 14 | 14 |
| 15 class ScheduleTryJobPipeline(BasePipeline): | 15 class ScheduleTryJobPipeline(BasePipeline): |
| 16 """A pipeline for scheduling a new try job for current build.""" | 16 """A pipeline for scheduling a new try job for current build.""" |
| 17 | 17 |
| 18 def _GetBuildProperties( | 18 def _GetBuildProperties( |
| 19 self, master_name, builder_name, build_number, good_revision, | 19 self, master_name, builder_name, build_number, good_revision, |
| 20 bad_revision, try_job_type, compile_targets, suspected_revisions): | 20 bad_revision, try_job_type, suspected_revisions): |
| 21 properties = { | 21 properties = { |
| 22 'recipe': 'findit/chromium/%s' % try_job_type, | 22 'recipe': 'findit/chromium/%s' % try_job_type, |
| 23 'good_revision': good_revision, | 23 'good_revision': good_revision, |
| 24 'bad_revision': bad_revision, | 24 'bad_revision': bad_revision, |
| 25 'target_mastername': master_name, | 25 'target_mastername': master_name, |
| 26 'referenced_build_url': buildbot.CreateBuildUrl( | 26 'referenced_build_url': buildbot.CreateBuildUrl( |
| 27 master_name, builder_name, build_number) | 27 master_name, builder_name, build_number) |
| 28 } | 28 } |
| 29 | 29 |
| 30 if try_job_type == TryJobType.COMPILE: | 30 if try_job_type == TryJobType.COMPILE: |
| 31 properties['target_buildername'] = builder_name | 31 properties['target_buildername'] = builder_name |
| 32 if compile_targets: | |
| 33 properties['compile_targets'] = compile_targets | |
| 34 else: # try_job_type is 'test'. | 32 else: # try_job_type is 'test'. |
| 35 properties['target_testername'] = builder_name | 33 properties['target_testername'] = builder_name |
| 36 | 34 |
| 37 if suspected_revisions: | 35 if suspected_revisions: |
| 38 properties['suspected_revisions'] = suspected_revisions | 36 properties['suspected_revisions'] = suspected_revisions |
| 39 | 37 |
| 40 return properties | 38 return properties |
| 41 | 39 |
| 42 # Arguments number differs from overridden method - pylint: disable=W0221 | 40 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 43 def run( | 41 def run( |
| 44 self, master_name, builder_name, build_number, good_revision, | 42 self, master_name, builder_name, build_number, good_revision, |
| 45 bad_revision, try_job_type, compile_targets, targeted_tests, | 43 bad_revision, try_job_type, compile_targets, targeted_tests, |
| 46 suspected_revisions): | 44 suspected_revisions): |
| 47 tryserver_mastername, tryserver_buildername = ( | 45 tryserver_mastername, tryserver_buildername = ( |
| 48 waterfall_config.GetTrybotForWaterfallBuilder( | 46 waterfall_config.GetTrybotForWaterfallBuilder( |
| 49 master_name, builder_name)) | 47 master_name, builder_name)) |
| 50 | 48 |
| 51 properties = self._GetBuildProperties( | 49 properties = self._GetBuildProperties( |
| 52 master_name, builder_name, build_number, good_revision, bad_revision, | 50 master_name, builder_name, build_number, good_revision, bad_revision, |
| 53 try_job_type, compile_targets, suspected_revisions) | 51 try_job_type, suspected_revisions) |
| 54 | 52 |
| 55 if try_job_type == TryJobType.COMPILE: | 53 if try_job_type == TryJobType.COMPILE: |
| 56 additional_parameters = {} | 54 additional_parameters = {'compile_targets': compile_targets} |
| 57 else: | 55 else: |
| 58 additional_parameters = {'tests': targeted_tests} | 56 additional_parameters = {'tests': targeted_tests} |
| 59 | 57 |
| 60 try_job = buildbucket_client.TryJob( | 58 try_job = buildbucket_client.TryJob( |
| 61 tryserver_mastername, tryserver_buildername, None, properties, [], | 59 tryserver_mastername, tryserver_buildername, None, properties, [], |
| 62 additional_parameters) | 60 additional_parameters) |
| 63 error, build = buildbucket_client.TriggerTryJobs([try_job])[0] | 61 error, build = buildbucket_client.TriggerTryJobs([try_job])[0] |
| 64 | 62 |
| 65 if error: # pragma: no cover | 63 if error: # pragma: no cover |
| 66 raise pipeline.Retry( | 64 raise pipeline.Retry( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 81 try_job_data = WfTryJobData.Create(build_id) | 79 try_job_data = WfTryJobData.Create(build_id) |
| 82 try_job_data.master_name = master_name | 80 try_job_data.master_name = master_name |
| 83 try_job_data.builder_name = builder_name | 81 try_job_data.builder_name = builder_name |
| 84 try_job_data.build_number = build_number | 82 try_job_data.build_number = build_number |
| 85 try_job_data.try_job_type = try_job_type | 83 try_job_data.try_job_type = try_job_type |
| 86 try_job_data.has_compile_targets = bool(compile_targets) | 84 try_job_data.has_compile_targets = bool(compile_targets) |
| 87 try_job_data.has_heuristic_results = bool(suspected_revisions) | 85 try_job_data.has_heuristic_results = bool(suspected_revisions) |
| 88 try_job_data.put() | 86 try_job_data.put() |
| 89 | 87 |
| 90 return build_id | 88 return build_id |
| OLD | NEW |