Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 from recipe_engine.recipe_api import Property | 5 from recipe_engine.recipe_api import Property |
| 6 | 6 |
| 7 DEPS = [ | 7 DEPS = [ |
| 8 'build/cipd', | 8 'build/cipd', |
| 9 'build/file', | 9 'build/file', |
| 10 'depot_tools/bot_update', | 10 'depot_tools/bot_update', |
| 11 'depot_tools/depot_tools', | 11 'depot_tools/depot_tools', |
| 12 'depot_tools/gclient', | 12 'depot_tools/gclient', |
| 13 'depot_tools/infra_paths', | 13 'depot_tools/infra_paths', |
| 14 'recipe_engine/json', | 14 'recipe_engine/json', |
| 15 'recipe_engine/path', | 15 'recipe_engine/path', |
| 16 'recipe_engine/platform', | 16 'recipe_engine/platform', |
| 17 'recipe_engine/properties', | 17 'recipe_engine/properties', |
| 18 'recipe_engine/python', | 18 'recipe_engine/python', |
| 19 'recipe_engine/step', | 19 'recipe_engine/step', |
| 20 ] | 20 ] |
| 21 | 21 |
| 22 | 22 |
| 23 def build_cipd_packages(api, repo, rev, mastername, buildername, buildnumber): | 23 # Builder name => [{GOOS: ..., GOARCH: ...}]. |
| 24 # Build packages locally. | 24 CROSS_COMPILING_BUILDERS = { |
| 25 'infra-continuous-precise-64': [{'GOOS': 'linux', 'GOARCH': 'arm'}], | |
| 26 } | |
| 27 | |
| 28 | |
| 29 def build_cipd_packages(api, repo, rev, mastername, buildername, buildnumber, | |
| 30 goos, goarch): | |
| 31 # 'goos' and 'goarch' used for cross-compilation of Go code. | |
| 32 step_suffix = '' | |
| 33 env = {} | |
|
nodir
2016/06/27 23:46:51
is it ok to exclude all existing vars?
Vadim Sh.
2016/06/27 23:48:25
I think recipe engine merges env dicts, not replac
| |
| 34 if goos or goarch: | |
| 35 assert goos and goarch, 'Both GOOS and GOARCH should be set' | |
| 36 step_suffix = ' [GOOS:%s GOARCH:%s]' % (goos, goarch) | |
| 37 env = {'GOOS': goos, 'GOARCH': goarch} | |
| 38 | |
| 39 # Build packages (don't upload them yet). | |
| 25 api.python( | 40 api.python( |
| 26 'cipd - build packages', | 41 'cipd - build packages' + step_suffix, |
| 27 api.path['checkout'].join('build', 'build.py'), | 42 api.path['checkout'].join('build', 'build.py'), |
| 28 ['--builder', api.properties.get('buildername')]) | 43 ['--builder', api.properties.get('buildername')], |
| 44 env=env) | |
| 29 | 45 |
| 30 # Verify they are good. | 46 # Verify they are good. Run tests only when building packages for the host |
| 31 api.python( | 47 # platform, since the host can't run binaries build with cross-compilation |
| 32 'cipd - test packages integrity', | 48 # enabled. |
| 33 api.path['checkout'].join('build', 'test_packages.py')) | 49 if not goos and not goarch: |
| 50 api.python( | |
| 51 'cipd - test packages integrity', | |
| 52 api.path['checkout'].join('build', 'test_packages.py')) | |
| 34 | 53 |
| 35 # Upload them, attach tags. | 54 # Upload them, attach tags. |
| 36 tags = [ | 55 tags = [ |
| 37 'buildbot_build:%s/%s/%s' % (mastername, buildername, buildnumber), | 56 'buildbot_build:%s/%s/%s' % (mastername, buildername, buildnumber), |
| 38 'git_repository:%s' % repo, | 57 'git_repository:%s' % repo, |
| 39 'git_revision:%s' % rev, | 58 'git_revision:%s' % rev, |
| 40 ] | 59 ] |
| 41 try: | 60 try: |
| 42 return api.python( | 61 return api.python( |
| 43 'cipd - upload packages', | 62 'cipd - upload packages' + step_suffix, |
| 44 api.path['checkout'].join('build', 'build.py'), | 63 api.path['checkout'].join('build', 'build.py'), |
| 45 [ | 64 [ |
| 46 '--no-rebuild', | 65 '--no-rebuild', |
| 47 '--upload', | 66 '--upload', |
| 48 '--service-account-json', | 67 '--service-account-json', |
| 49 api.cipd.default_bot_service_account_credentials, | 68 api.cipd.default_bot_service_account_credentials, |
| 50 '--json-output', api.json.output(), | 69 '--json-output', api.json.output(), |
| 51 '--builder', api.properties.get('buildername'), | 70 '--builder', api.properties.get('buildername'), |
| 52 ] + ['--tags'] + tags) | 71 ] + ['--tags'] + tags, |
| 72 env=env) | |
| 53 finally: | 73 finally: |
| 54 step_result = api.step.active_result | 74 step_result = api.step.active_result |
| 55 output = step_result.json.output or {} | 75 output = step_result.json.output or {} |
| 56 p = step_result.presentation | 76 p = step_result.presentation |
| 57 for pkg in output.get('succeeded', []): | 77 for pkg in output.get('succeeded', []): |
| 58 info = pkg['info'] | 78 info = pkg['info'] |
| 59 title = '%s %s' % (info['package'], info['instance_id']) | 79 title = '%s %s' % (info['package'], info['instance_id']) |
| 60 p.links[title] = info.get('url', 'http://example.com/not-implemented-yet') | 80 p.links[title] = info.get('url', 'http://example.com/not-implemented-yet') |
| 61 | 81 |
| 62 | 82 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 api.path['checkout'].join('go', 'env.py'), | 153 api.path['checkout'].join('go', 'env.py'), |
| 134 ['go', 'version']) | 154 ['go', 'version']) |
| 135 # Note: env.py knows how to expand 'python' into sys.executable. | 155 # Note: env.py knows how to expand 'python' into sys.executable. |
| 136 api.python( | 156 api.python( |
| 137 'infra go tests', | 157 'infra go tests', |
| 138 api.path['checkout'].join('go', 'env.py'), | 158 api.path['checkout'].join('go', 'env.py'), |
| 139 ['python', api.path['checkout'].join('go', 'test.py')]) | 159 ['python', api.path['checkout'].join('go', 'test.py')]) |
| 140 | 160 |
| 141 if buildnumber != -1: | 161 if buildnumber != -1: |
| 142 build_cipd_packages(api, repo_name, rev, mastername, buildername, | 162 build_cipd_packages(api, repo_name, rev, mastername, buildername, |
| 143 buildnumber) | 163 buildnumber, None, None) |
| 164 for spec in CROSS_COMPILING_BUILDERS.get(buildername, []): | |
| 165 build_cipd_packages(api, repo_name, rev, mastername, buildername, | |
| 166 buildnumber, spec['GOOS'], spec['GOARCH']) | |
| 144 else: | 167 else: |
| 145 result = api.step('cipd - not building packages', None) | 168 result = api.step('cipd - not building packages', None) |
| 146 result.presentation.status = api.step.WARNING | 169 result.presentation.status = api.step.WARNING |
| 147 | 170 |
| 148 # Only build luci-go executables on 64 bits, public CI. | 171 # Only build luci-go executables on 64 bits, public CI. |
| 149 if project_name == 'infra' and buildername.endswith('-64'): | 172 if project_name == 'infra' and buildername.endswith('-64'): |
| 150 build_luci(api) | 173 build_luci(api) |
| 151 | 174 |
| 152 | 175 |
| 153 def GenTests(api): | 176 def GenTests(api): |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 api.properties.git_scheduled( | 228 api.properties.git_scheduled( |
| 206 path_config='kitchen', | 229 path_config='kitchen', |
| 207 buildername='infra-continuous-64', | 230 buildername='infra-continuous-64', |
| 208 buildnumber=123, | 231 buildnumber=123, |
| 209 mastername='chromium.infra', | 232 mastername='chromium.infra', |
| 210 repository='https://chromium.googlesource.com/infra/infra', | 233 repository='https://chromium.googlesource.com/infra/infra', |
| 211 ) | 234 ) |
| 212 ) | 235 ) |
| 213 | 236 |
| 214 yield ( | 237 yield ( |
| 238 api.test('infra-cross-compile') + | |
| 239 api.properties.git_scheduled( | |
| 240 path_config='kitchen', | |
| 241 buildername='infra-continuous-precise-64', | |
| 242 buildnumber=123, | |
| 243 mastername='chromium.infra', | |
| 244 repository='https://chromium.googlesource.com/infra/infra', | |
| 245 ) + | |
| 246 api.override_step_data( | |
| 247 'cipd - upload packages', api.json.output(cipd_json_output)) + | |
| 248 api.override_step_data( | |
| 249 'cipd - upload packages [GOOS:linux GOARCH:arm]', | |
| 250 api.json.output(cipd_json_output)) | |
| 251 ) | |
| 252 | |
| 253 yield ( | |
| 215 api.test('infra_swarming') + | 254 api.test('infra_swarming') + |
| 216 api.properties.git_scheduled( | 255 api.properties.git_scheduled( |
| 217 path_config='kitchen', | 256 path_config='kitchen', |
| 218 buildername='infra-continuous-32', | 257 buildername='infra-continuous-32', |
| 219 buildnumber=-1, | 258 buildnumber=-1, |
| 220 mastername='chromium.infra', | 259 mastername='chromium.infra', |
| 221 repository='https://chromium.googlesource.com/infra/infra', | 260 repository='https://chromium.googlesource.com/infra/infra', |
| 222 ) | 261 ) |
| 223 ) | 262 ) |
| OLD | NEW |