| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python | |
| 2 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 3 # for details. All rights reserved. Use of this source code is governed by a | |
| 4 # BSD-style license that can be found in the LICENSE file. | |
| 5 | |
| 6 """ | |
| 7 Dartium on Android buildbot steps. | |
| 8 | |
| 9 Runs steps after the buildbot builds Dartium on Android, | |
| 10 which should upload the APK to an attached device, and run | |
| 11 Dart and chromium tests on it. | |
| 12 """ | |
| 13 | |
| 14 import optparse | |
| 15 import os | |
| 16 import string | |
| 17 import subprocess | |
| 18 import sys | |
| 19 | |
| 20 import bot | |
| 21 import bot_utils | |
| 22 | |
| 23 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| 24 sys.path.append(os.path.join(SCRIPT_DIR, '..')) | |
| 25 import utils | |
| 26 | |
| 27 CS_LOCATION = 'apks/ContentShell.apk' | |
| 28 | |
| 29 def GetOptionsParser(): | |
| 30 parser = optparse.OptionParser("usage: %prog [options]") | |
| 31 parser.add_option("--build-products-dir", | |
| 32 help="The directory containing the products of the build.") | |
| 33 return parser | |
| 34 | |
| 35 | |
| 36 def UploadSetACL(gsutil, local, remote): | |
| 37 gsutil.upload(local, remote, public=True) | |
| 38 | |
| 39 | |
| 40 def UploadAPKs(options): | |
| 41 with bot.BuildStep('Upload apk'): | |
| 42 bot_name = os.environ.get('BUILDBOT_BUILDERNAME') | |
| 43 on_fyi = 'fyi-' in os.environ.get('BUILDBOT_SCHEDULER') | |
| 44 if '-integration' in bot_name or on_fyi: | |
| 45 return | |
| 46 channel = bot_utils.GetChannelFromName(bot_name) | |
| 47 namer = bot_utils.GCSNamer(channel=channel) | |
| 48 gsutil = bot_utils.GSUtil() | |
| 49 | |
| 50 web_link_prefix = 'https://storage.cloud.google.com/' | |
| 51 | |
| 52 # Archive content shell | |
| 53 local = os.path.join(options.build_products_dir, CS_LOCATION) | |
| 54 | |
| 55 for revision in [utils.GetArchiveVersion(), 'latest']: | |
| 56 # TODO(whesse): pass in arch and mode from reciepe | |
| 57 remote = namer.dartium_android_apk_filepath(revision, | |
| 58 'content_shell-android', | |
| 59 'arm', | |
| 60 'release') | |
| 61 content_shell_link = string.replace(remote, 'gs://', web_link_prefix) | |
| 62 UploadSetACL(gsutil, local, remote) | |
| 63 print "Uploaded content shell, available from: %s" % content_shell_link | |
| 64 | |
| 65 | |
| 66 def RunContentShellTests(options): | |
| 67 with bot.BuildStep('ContentShell tests'): | |
| 68 subprocess.check_call([os.path.join(SCRIPT_DIR, 'run_android_tests.sh'), | |
| 69 os.path.join(options.build_products_dir, CS_LOCATION)]) | |
| 70 | |
| 71 | |
| 72 def main(): | |
| 73 if sys.platform != 'linux2': | |
| 74 print "This script was only tested on linux. Please run it on linux!" | |
| 75 sys.exit(1) | |
| 76 | |
| 77 parser = GetOptionsParser() | |
| 78 (options, args) = parser.parse_args() | |
| 79 | |
| 80 if not options.build_products_dir: | |
| 81 print "No build products directory given." | |
| 82 sys.exit(1) | |
| 83 | |
| 84 UploadAPKs(options) | |
| 85 RunContentShellTests(options) | |
| 86 sys.exit(0) | |
| 87 | |
| 88 if __name__ == '__main__': | |
| 89 main() | |
| OLD | NEW |