Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 import contextlib | 5 import contextlib |
| 6 | 6 |
| 7 DEPS = [ | 7 DEPS = [ |
| 8 'depot_tools/git', | 8 'depot_tools/git', |
| 9 'file', | 9 'file', |
| 10 'gsutil', | 10 'gsutil', |
| 11 'recipe_engine/json', | |
| 11 'recipe_engine/path', | 12 'recipe_engine/path', |
| 12 'recipe_engine/platform', | 13 'recipe_engine/platform', |
| 13 'recipe_engine/properties', | 14 'recipe_engine/properties', |
| 14 'recipe_engine/step', | 15 'recipe_engine/step', |
| 16 'recipe_engine/python', | |
| 15 ] | 17 ] |
| 16 | 18 |
| 17 BUCKET_NAME = 'flutter_infra' | 19 BUCKET_NAME = 'flutter_infra' |
| 18 | 20 |
| 19 | 21 |
| 20 def GetCloudPath(api, git_hash, path): | 22 def GetCloudPath(api, git_hash, path): |
| 21 return 'flutter/%s/%s' % (git_hash, path) | 23 return 'flutter/%s/%s' % (git_hash, path) |
| 22 | 24 |
| 23 | 25 |
| 24 def AnalyzeFlutter(api): | 26 def AnalyzeFlutter(api): |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 if api.platform.is_linux: | 122 if api.platform.is_linux: |
| 121 cloud_path = GetCloudPath(api, git_hash, 'examples/%s' % apk_name) | 123 cloud_path = GetCloudPath(api, git_hash, 'examples/%s' % apk_name) |
| 122 api.gsutil.upload(app_path.join('build/app.apk'), BUCKET_NAME, cloud_path, | 124 api.gsutil.upload(app_path.join('build/app.apk'), BUCKET_NAME, cloud_path, |
| 123 link_name=apk_name, name='upload %s' % apk_name) | 125 link_name=apk_name, name='upload %s' % apk_name) |
| 124 | 126 |
| 125 # TODO(eseidel): We should not have to hard-code the desired apk name here. | 127 # TODO(eseidel): We should not have to hard-code the desired apk name here. |
| 126 ArchiveAPK(api, 'examples/stocks', 'Stocks.apk') | 128 ArchiveAPK(api, 'examples/stocks', 'Stocks.apk') |
| 127 ArchiveAPK(api, 'examples/material_gallery', 'Gallery.apk') | 129 ArchiveAPK(api, 'examples/material_gallery', 'Gallery.apk') |
| 128 | 130 |
| 129 | 131 |
| 132 def RunFindXcode(api, step_name, target_version=None): | |
| 133 """Runs the `build/scripts/slave/ios/find_xcode.py` utility. | |
| 134 | |
| 135 Retrieves information about xcode installations and to activate a specific | |
| 136 version of Xcode. | |
| 137 """ | |
| 138 args = ['--json-file', api.json.output()] | |
| 139 | |
| 140 if target_version is not None: | |
| 141 args.extend(['--version', target_version]) | |
| 142 | |
| 143 result = api.python(step_name, api.path['build'].join('scripts', 'slave', | |
| 144 'ios', 'find_xcode.py'), args) | |
| 145 | |
| 146 return result.json.output | |
| 147 | |
| 148 | |
| 149 def SetupXcode(api): | |
| 150 xcode_json = RunFindXcode(api, 'enumerate_xcode_installations') | |
| 151 installations = xcode_json["installations"] | |
| 152 activate_version = None | |
| 153 for key in installations: | |
| 154 version = installations[key].split()[0] | |
| 155 if version.startswith('7.'): | |
| 156 activate_version = version | |
| 157 break | |
| 158 if not activate_version: | |
| 159 raise api.step.StepFailure('Xcode version 7 or above not found') | |
| 160 RunFindXcode(api, 'set_xcode_version', target_version=activate_version) | |
| 161 | |
| 162 | |
| 130 def RunSteps(api): | 163 def RunSteps(api): |
| 131 # buildbot sets 'clobber' to the empty string which is falsey, check with 'in' | 164 # buildbot sets 'clobber' to the empty string which is falsey, check with 'in' |
| 132 if 'clobber' in api.properties: | 165 if 'clobber' in api.properties: |
| 133 api.file.rmcontents('everything', api.path['slave_build']) | 166 api.file.rmcontents('everything', api.path['slave_build']) |
| 134 | 167 |
| 135 git_hash = api.git.checkout( | 168 git_hash = api.git.checkout( |
| 136 'https://chromium.googlesource.com/external/github.com/flutter/flutter', | 169 'https://chromium.googlesource.com/external/github.com/flutter/flutter', |
| 137 recursive=True, set_got_revision=True) | 170 recursive=True, set_got_revision=True) |
| 138 checkout = api.path['checkout'] | 171 checkout = api.path['checkout'] |
| 139 | 172 |
| 140 api.step('download android tools', | 173 api.step('download android tools', |
| 141 [checkout.join('infra', 'download_android_tools.py')]) | 174 [checkout.join('infra', 'download_android_tools.py')]) |
| 142 | 175 |
| 143 dart_bin = checkout.join('bin', 'cache', 'dart-sdk', 'bin') | 176 dart_bin = checkout.join('bin', 'cache', 'dart-sdk', 'bin') |
| 144 flutter_bin = checkout.join('bin') | 177 flutter_bin = checkout.join('bin') |
| 145 # TODO(eseidel): This is named exactly '.pub-cache' as a hack around | 178 # TODO(eseidel): This is named exactly '.pub-cache' as a hack around |
| 146 # a regexp in flutter_tools analyze.dart which is in turn a hack around: | 179 # a regexp in flutter_tools analyze.dart which is in turn a hack around: |
| 147 # https://github.com/dart-lang/sdk/issues/25722 | 180 # https://github.com/dart-lang/sdk/issues/25722 |
| 148 pub_cache = api.path['slave_build'].join('.pub-cache') | 181 pub_cache = api.path['slave_build'].join('.pub-cache') |
| 149 env = { | 182 env = { |
| 150 'PATH': api.path.pathsep.join((str(flutter_bin), str(dart_bin), | 183 'PATH': api.path.pathsep.join((str(flutter_bin), str(dart_bin), |
| 151 '%(PATH)s')), | 184 '%(PATH)s')), |
| 152 # Setup our own pub_cache to not affect other slaves on this machine. | 185 # Setup our own pub_cache to not affect other slaves on this machine. |
| 153 'PUB_CACHE': pub_cache, | 186 'PUB_CACHE': pub_cache, |
| 154 'ANDROID_HOME': checkout.join('infra', 'android_tools'), | 187 'ANDROID_HOME': checkout.join('infra', 'android_tools'), |
| 155 } | 188 } |
| 156 | 189 |
| 157 # The context adds dart-sdk tools to PATH sets PUB_CACHE. | 190 # The context adds dart-sdk tools to PATH sets PUB_CACHE. |
| 158 with api.step.context({'env': env}): | 191 with api.step.context({'env': env}): |
| 192 if api.platform.is_mac: | |
| 193 SetupXcode(api) | |
| 194 | |
| 159 # Must be first to download dependencies for later steps. | 195 # Must be first to download dependencies for later steps. |
| 160 api.step('flutter doctor', ['flutter', 'doctor']) | 196 api.step('flutter doctor', ['flutter', 'doctor']) |
| 161 api.step('update packages', ['flutter', 'update-packages']) | 197 api.step('update packages', ['flutter', 'update-packages']) |
| 162 AnalyzeFlutter(api) | 198 AnalyzeFlutter(api) |
| 163 TestFlutterPackagesAndExamples(api) | 199 TestFlutterPackagesAndExamples(api) |
| 164 BuildExamples(api, git_hash) | 200 BuildExamples(api, git_hash) |
| 165 | 201 |
| 166 # TODO(yjbanov): we do not yet have Android devices hooked up, nor do we | 202 # TODO(yjbanov): we do not yet have Android devices hooked up, nor do we |
| 167 # support the Android emulator. For now, only run on iOS Simulator. | 203 # support the Android emulator. For now, only run on iOS Simulator. |
| 168 if api.platform.is_mac: | 204 if api.platform.is_mac: |
| 169 TestCreateAndLaunch(api) | 205 TestCreateAndLaunch(api) |
| 170 | 206 |
| 171 # TODO(eseidel): We only want to generate one copy of the docs at a time | 207 # TODO(eseidel): We only want to generate one copy of the docs at a time |
| 172 # otherwise multiple rsyncs could race, causing badness. We'll eventually | 208 # otherwise multiple rsyncs could race, causing badness. We'll eventually |
| 173 # need both a lock on the bucket, as well as some assurance that we're | 209 # need both a lock on the bucket, as well as some assurance that we're |
| 174 # always moving the docs forward. Possibly by using a separate builder. | 210 # always moving the docs forward. Possibly by using a separate builder. |
| 175 # Until then, only generate on linux to reduce the chance of race. | 211 # Until then, only generate on linux to reduce the chance of race. |
| 176 if api.platform.is_linux: | 212 if api.platform.is_linux: |
| 177 # TODO(eseidel): Is there a way for GenerateDocs to read PUB_CACHE from | 213 # TODO(eseidel): Is there a way for GenerateDocs to read PUB_CACHE from |
| 178 # the env instead of me passing it in? | 214 # the env instead of me passing it in? |
| 179 GenerateDocs(api, pub_cache) | 215 GenerateDocs(api, pub_cache) |
| 180 | 216 |
| 181 | 217 |
| 182 def GenTests(api): | 218 def GenTests(api): |
| 183 for platform in ('mac', 'linux'): | 219 for platform in ('mac', 'linux'): |
| 184 yield (api.test(platform) + api.platform(platform, 64) + | 220 test = (api.test(platform) + api.platform(platform, 64) + |
| 185 api.properties(clobber='')) | 221 api.properties(clobber='')) |
| 222 | |
| 223 if platform == 'mac': | |
| 224 test = (test + | |
|
iannucci
2016/03/07 07:30:21
nit: I think `test += ` will do the right thing
yjbanov
2016/03/07 17:47:07
Done.
| |
| 225 api.step_data('enumerate_xcode_installations', api.json.output({ | |
| 226 'installations': { | |
| 227 '/some/path': '7.2.1 build_number' | |
| 228 } | |
| 229 })) + | |
| 230 api.step_data('set_xcode_version', api.json.output({}))) | |
| 231 | |
| 232 yield test | |
| OLD | NEW |