OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import logging |
| 6 |
| 7 from common import chromium_deps |
| 8 from waterfall.base_pipeline import BasePipeline |
| 9 |
| 10 |
| 11 def _GetOSPlatformName(master_name, builder_name): # pragma: no cover |
| 12 """Returns the OS platform name based on the master and builder.""" |
| 13 # TODO: make buildbot yield OS platform name as a build property and use it. |
| 14 # The code below is just a workaround. |
| 15 builder_name = builder_name.lower() |
| 16 if master_name == 'chromium.win': |
| 17 return 'win' |
| 18 elif master_name == 'chromium.linux': |
| 19 if 'android' in builder_name: |
| 20 return 'android' |
| 21 else: |
| 22 return 'unix' |
| 23 elif master_name == 'chromium.chromiumos': |
| 24 return 'unix' |
| 25 else: |
| 26 os_map = { |
| 27 'win': 'win', |
| 28 'linux': 'unix', |
| 29 'chromiumos': 'unix', |
| 30 'chromeos': 'unix', |
| 31 'android': 'android', |
| 32 'mac': 'mac', |
| 33 'ios': 'ios', |
| 34 } |
| 35 for os_name in os_map.keys(): |
| 36 if os_name in builder_name: |
| 37 return os_map[os_name] |
| 38 |
| 39 logging.warn('Failed to detect the OS platform of builder "%s".', |
| 40 builder_name) |
| 41 return 'all' # Default to all platform. |
| 42 |
| 43 |
| 44 def _GetDependencies(chromium_revision, os_platform): |
| 45 """Returns the dependencies used by the specified chromium revision.""" |
| 46 deps = {} |
| 47 for path, dependency in chromium_deps.GetChromeDependency( |
| 48 chromium_revision, os_platform).iteritems(): |
| 49 deps[path] = { |
| 50 'repo_url': dependency.repo_url, |
| 51 'revision': dependency.revision, |
| 52 } |
| 53 |
| 54 return deps |
| 55 |
| 56 |
| 57 def _DetectDEPSRolls(change_logs, os_platform): |
| 58 """Detect DEPS rolls in the given CL change logs. |
| 59 |
| 60 Args: |
| 61 change_logs (dict): Output of pipeline PullChangelogPipeline.run(). |
| 62 |
| 63 Returns: |
| 64 A dict in the following form: |
| 65 { |
| 66 'git_revision': [ |
| 67 { |
| 68 'path': 'src/path/to/dependency/', |
| 69 'repo_url': 'https://url/to/dependency/repo.git', |
| 70 'new_revision': 'git_hash1', |
| 71 'old_revision': 'git_hash2', |
| 72 }, |
| 73 ... |
| 74 ], |
| 75 ... |
| 76 } |
| 77 """ |
| 78 deps_rolls = {} |
| 79 for revision, change_log in change_logs.iteritems(): |
| 80 # Check DEPS roll only if the chromium DEPS file is changed by the CL. |
| 81 for touched_file in change_log['touched_files']: |
| 82 if touched_file['new_path'] == 'DEPS': |
| 83 # In git, r^ refers to the previous revision of r. |
| 84 old_revision = '%s^' % revision |
| 85 rolls = chromium_deps.GetChromiumDEPSRolls( |
| 86 old_revision, revision, os_platform) |
| 87 deps_rolls[revision] = [roll.ToDict() for roll in rolls] |
| 88 break |
| 89 |
| 90 return deps_rolls |
| 91 |
| 92 |
| 93 class ExtractDEPSInfoPipeline(BasePipeline): |
| 94 """A pipeline to extract information of DEPS and dependency rolls.""" |
| 95 |
| 96 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 97 def run(self, failure_info, change_logs): |
| 98 """ |
| 99 Args: |
| 100 failure_info (dict): Output of pipeline DetectFirstFailurePipeline.run(). |
| 101 change_logs (dict): Output of pipeline PullChangelogPipeline.run(). |
| 102 |
| 103 Returns: |
| 104 A dict with the following form: |
| 105 { |
| 106 'deps': { |
| 107 'path/to/dependency/': { |
| 108 'revision': 'git_hash', |
| 109 'repo_url': 'https://url/to/dependency/repo.git', |
| 110 }, |
| 111 ... |
| 112 }, |
| 113 'deps_rolls': { |
| 114 'git_revision': [ |
| 115 { |
| 116 'path': 'src/path/to/dependency/', |
| 117 'repo_url': 'https://url/to/dependency/repo.git', |
| 118 'new_revision': 'git_hash1', |
| 119 'old_revision': 'git_hash2', |
| 120 }, |
| 121 ... |
| 122 ], |
| 123 ... |
| 124 } |
| 125 } |
| 126 """ |
| 127 chromium_revision = failure_info['chromium_revision'] |
| 128 os_platform = _GetOSPlatformName( |
| 129 failure_info['master_name'], failure_info['builder_name']) |
| 130 |
| 131 return { |
| 132 'deps': _GetDependencies(chromium_revision, os_platform), |
| 133 'deps_rolls': _DetectDEPSRolls(change_logs, os_platform) |
| 134 } |
OLD | NEW |