| OLD | NEW |
| (Empty) |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from recipe_engine.recipe_api import Property | |
| 6 | |
| 7 DEPS = [ | |
| 8 'cipd', | |
| 9 'depot_tools/bot_update', | |
| 10 'depot_tools/depot_tools', | |
| 11 'file', | |
| 12 'depot_tools/gclient', | |
| 13 'recipe_engine/json', | |
| 14 'recipe_engine/path', | |
| 15 'recipe_engine/platform', | |
| 16 'recipe_engine/properties', | |
| 17 'recipe_engine/python', | |
| 18 'recipe_engine/step', | |
| 19 ] | |
| 20 | |
| 21 | |
| 22 def build_cipd_packages(api, repo, rev, mastername, buildername, buildnumber): | |
| 23 # Build packages locally. | |
| 24 api.python( | |
| 25 'cipd - build packages', | |
| 26 api.path['checkout'].join('build', 'build.py'), | |
| 27 ['--builder', api.properties.get('buildername')]) | |
| 28 | |
| 29 # Verify they are good. | |
| 30 api.python( | |
| 31 'cipd - test packages integrity', | |
| 32 api.path['checkout'].join('build', 'test_packages.py')) | |
| 33 | |
| 34 # Upload them, attach tags. | |
| 35 tags = [ | |
| 36 'buildbot_build:%s/%s/%s' % (mastername, buildername, buildnumber), | |
| 37 'git_repository:%s' % repo, | |
| 38 'git_revision:%s' % rev, | |
| 39 ] | |
| 40 try: | |
| 41 return api.python( | |
| 42 'cipd - upload packages', | |
| 43 api.path['checkout'].join('build', 'build.py'), | |
| 44 [ | |
| 45 '--no-rebuild', | |
| 46 '--upload', | |
| 47 '--service-account-json', | |
| 48 api.cipd.default_bot_service_account_credentials, | |
| 49 '--json-output', api.json.output(), | |
| 50 '--builder', api.properties.get('buildername'), | |
| 51 ] + ['--tags'] + tags) | |
| 52 finally: | |
| 53 step_result = api.step.active_result | |
| 54 output = step_result.json.output or {} | |
| 55 p = step_result.presentation | |
| 56 for pkg in output.get('succeeded', []): | |
| 57 info = pkg['info'] | |
| 58 title = '%s %s' % (info['package'], info['instance_id']) | |
| 59 p.links[title] = info.get('url', 'http://example.com/not-implemented-yet') | |
| 60 | |
| 61 | |
| 62 def build_luci(api): | |
| 63 go_bin = api.path['checkout'].join('go', 'bin') | |
| 64 go_env = api.path['checkout'].join('go', 'env.py') | |
| 65 api.file.rmcontents('clean go bin', go_bin) | |
| 66 | |
| 67 api.python( | |
| 68 'build luci-go', go_env, | |
| 69 ['go', 'install', 'github.com/luci/luci-go/client/cmd/...']) | |
| 70 | |
| 71 files = sorted(api.file.listdir('listing go bin', go_bin)) | |
| 72 absfiles = [api.path.join(go_bin, i) for i in files] | |
| 73 api.python( | |
| 74 'upload go bin', | |
| 75 api.depot_tools.upload_to_google_storage_path, | |
| 76 ['-b', 'chromium-luci'] + absfiles) | |
| 77 for name, abspath in zip(files, absfiles): | |
| 78 sha1 = api.file.read( | |
| 79 '%s sha1' % str(name), abspath + '.sha1', | |
| 80 test_data='0123456789abcdeffedcba987654321012345678') | |
| 81 api.step.active_result.presentation.step_text = sha1 | |
| 82 | |
| 83 | |
| 84 PROPERTIES = { | |
| 85 'mastername': Property(), | |
| 86 'buildername': Property(), | |
| 87 'buildnumber': Property(default=-1, kind=int), | |
| 88 } | |
| 89 | |
| 90 def RunSteps(api, mastername, buildername, buildnumber): | |
| 91 if buildername.startswith('infra-internal-continuous'): | |
| 92 project_name = 'infra_internal' | |
| 93 repo_name = 'https://chrome-internal.googlesource.com/infra/infra_internal' | |
| 94 elif buildername.startswith('infra-continuous'): | |
| 95 project_name = 'infra' | |
| 96 repo_name = 'https://chromium.googlesource.com/infra/infra' | |
| 97 else: # pragma: no cover | |
| 98 raise ValueError( | |
| 99 'This recipe is not intended for builder %s. ' % buildername) | |
| 100 | |
| 101 api.gclient.set_config(project_name) | |
| 102 bot_update_step = api.bot_update.ensure_checkout(force=True) | |
| 103 api.gclient.runhooks() | |
| 104 | |
| 105 # Whatever is checked out by bot_update. It is usually equal to | |
| 106 # api.properties['revision'] except when the build was triggered manually | |
| 107 # ('revision' property is missing in that case). | |
| 108 rev = bot_update_step.presentation.properties['got_revision'] | |
| 109 | |
| 110 with api.step.defer_results(): | |
| 111 # Run Linux tests everywhere, Windows tests only on public CI. | |
| 112 if api.platform.is_linux or project_name == 'infra': | |
| 113 api.python( | |
| 114 'infra python tests', | |
| 115 'test.py', | |
| 116 ['test'], | |
| 117 cwd=api.path['checkout']) | |
| 118 | |
| 119 # Run Glyco tests only on public Linux\Mac CI. | |
| 120 if project_name == 'infra' and not api.platform.is_win: | |
| 121 api.python( | |
| 122 'Glyco tests', | |
| 123 api.path['checkout'].join('glyco', 'tests', 'run_all_tests.py'), | |
| 124 [], | |
| 125 cwd=api.path['checkout']) | |
| 126 | |
| 127 # This downloads Go third parties, so that the next step doesn't have junk | |
| 128 # output in it. | |
| 129 api.python( | |
| 130 'go third parties', | |
| 131 api.path['checkout'].join('go', 'env.py'), | |
| 132 ['go', 'version']) | |
| 133 # Note: env.py knows how to expand 'python' into sys.executable. | |
| 134 api.python( | |
| 135 'infra go tests', | |
| 136 api.path['checkout'].join('go', 'env.py'), | |
| 137 ['python', api.path['checkout'].join('go', 'test.py')]) | |
| 138 | |
| 139 if buildnumber != -1: | |
| 140 build_cipd_packages(api, repo_name, rev, mastername, buildername, | |
| 141 buildnumber) | |
| 142 else: | |
| 143 result = api.step('cipd - not building packages', None) | |
| 144 result.presentation.status = api.step.WARNING | |
| 145 | |
| 146 # Only build luci-go executables on 64 bits, public CI. | |
| 147 if project_name == 'infra' and buildername.endswith('-64'): | |
| 148 build_luci(api) | |
| 149 | |
| 150 | |
| 151 def GenTests(api): | |
| 152 cipd_json_output = { | |
| 153 'succeeded': [ | |
| 154 { | |
| 155 'info': { | |
| 156 'instance_id': 'abcdefabcdef63ad814cd1dfffe2fcfc9f81299c', | |
| 157 'package': 'infra/tools/some_tool/linux-bitness', | |
| 158 }, | |
| 159 'pkg_def_name': 'some_tool', | |
| 160 }, | |
| 161 ], | |
| 162 'failed': [], | |
| 163 } | |
| 164 | |
| 165 yield ( | |
| 166 api.test('infra') + | |
| 167 api.properties.git_scheduled( | |
| 168 path_config='kitchen', | |
| 169 buildername='infra-continuous', | |
| 170 buildnumber=123, | |
| 171 mastername='chromium.infra', | |
| 172 repository='https://chromium.googlesource.com/infra/infra', | |
| 173 ) + | |
| 174 api.override_step_data( | |
| 175 'cipd - upload packages', api.json.output(cipd_json_output)) | |
| 176 ) | |
| 177 yield ( | |
| 178 api.test('infra_win') + | |
| 179 api.properties.git_scheduled( | |
| 180 path_config='kitchen', | |
| 181 buildername='infra-continuous', | |
| 182 buildnumber=123, | |
| 183 mastername='chromium.infra', | |
| 184 repository='https://chromium.googlesource.com/infra/infra', | |
| 185 ) + | |
| 186 api.platform.name('win') | |
| 187 ) | |
| 188 yield ( | |
| 189 api.test('infra_internal') + | |
| 190 api.properties.git_scheduled( | |
| 191 path_config='kitchen', | |
| 192 buildername='infra-internal-continuous', | |
| 193 buildnumber=123, | |
| 194 mastername='internal.infra', | |
| 195 repository= | |
| 196 'https://chrome-internal.googlesource.com/infra/infra_internal', | |
| 197 ) + | |
| 198 api.override_step_data( | |
| 199 'cipd - upload packages', api.json.output(cipd_json_output)) | |
| 200 ) | |
| 201 yield ( | |
| 202 api.test('infra-64') + | |
| 203 api.properties.git_scheduled( | |
| 204 path_config='kitchen', | |
| 205 buildername='infra-continuous-64', | |
| 206 buildnumber=123, | |
| 207 mastername='chromium.infra', | |
| 208 repository='https://chromium.googlesource.com/infra/infra', | |
| 209 ) | |
| 210 ) | |
| 211 | |
| 212 yield ( | |
| 213 api.test('infra_swarming') + | |
| 214 api.properties.git_scheduled( | |
| 215 path_config='kitchen', | |
| 216 buildername='infra-continuous-32', | |
| 217 buildnumber=-1, | |
| 218 mastername='chromium.infra', | |
| 219 repository='https://chromium.googlesource.com/infra/infra', | |
| 220 ) | |
| 221 ) | |
| OLD | NEW |