2018-02-01 18:38:13 +00:00
|
|
|
# Copyright 2018 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
|
import math
|
|
|
|
|
|
|
|
|
|
|
|
DEPS = [
|
2018-09-27 18:24:33 +00:00
|
|
|
'recipe_engine/context',
|
|
|
|
'recipe_engine/json',
|
2018-02-05 18:16:34 +00:00
|
|
|
'recipe_engine/path',
|
2018-02-01 18:38:13 +00:00
|
|
|
'recipe_engine/properties',
|
2018-09-27 18:24:33 +00:00
|
|
|
'recipe_engine/raw_io',
|
2018-02-01 18:38:13 +00:00
|
|
|
'recipe_engine/step',
|
|
|
|
]
|
|
|
|
|
2018-11-26 17:36:34 +00:00
|
|
|
CF_X86_PHONE_ENG_LUNCH_TARGET = 'cf_x86_phone-eng'
|
|
|
|
SDK_LUNCH_TARGET = 'sdk'
|
|
|
|
|
|
|
|
LUNCH_TARGET_TO_MMMA_TARGETS = {
|
|
|
|
CF_X86_PHONE_ENG_LUNCH_TARGET: 'frameworks/base/core/jni,external/skia',
|
|
|
|
SDK_LUNCH_TARGET: 'external/skia',
|
|
|
|
}
|
|
|
|
|
2018-02-01 18:38:13 +00:00
|
|
|
|
|
|
|
def RunSteps(api):
|
|
|
|
buildername = api.properties['buildername']
|
|
|
|
issue = api.properties.get('patch_issue')
|
|
|
|
patchset = api.properties.get('patch_set')
|
|
|
|
if not issue or not patchset:
|
|
|
|
# This bot currently only supports trybot runs because:
|
|
|
|
# Non-trybot runs could fail if the Android tree is red. We mitigate this
|
|
|
|
# for trybot runs by verifying that runs without the patch succeed. We do
|
|
|
|
# not currently have a way to do the same for non-trybot runs.
|
|
|
|
raise Exception('%s can only be run as a trybot.' % buildername)
|
|
|
|
|
2018-11-26 17:36:34 +00:00
|
|
|
if CF_X86_PHONE_ENG_LUNCH_TARGET in buildername:
|
|
|
|
lunch_target = CF_X86_PHONE_ENG_LUNCH_TARGET
|
|
|
|
mmma_targets = LUNCH_TARGET_TO_MMMA_TARGETS[lunch_target]
|
|
|
|
elif SDK_LUNCH_TARGET in buildername:
|
|
|
|
lunch_target = SDK_LUNCH_TARGET
|
|
|
|
mmma_targets = LUNCH_TARGET_TO_MMMA_TARGETS[SDK_LUNCH_TARGET]
|
|
|
|
else:
|
|
|
|
raise Exception('Lunch target in %s is not recognized.' % buildername)
|
|
|
|
|
2018-02-05 18:16:34 +00:00
|
|
|
infrabots_dir = api.path['start_dir'].join('skia', 'infra', 'bots')
|
2018-02-01 18:38:13 +00:00
|
|
|
trigger_wait_ac_script = infrabots_dir.join('android_compile',
|
|
|
|
'trigger_wait_ac_task.py')
|
|
|
|
|
2018-09-27 18:24:33 +00:00
|
|
|
# Trigger a compile task on the android compile server and wait for it to
|
2018-02-01 18:38:13 +00:00
|
|
|
# complete.
|
|
|
|
cmd = ['python', trigger_wait_ac_script,
|
2018-11-26 17:36:34 +00:00
|
|
|
'--lunch_target', lunch_target,
|
|
|
|
'--mmma_targets', mmma_targets,
|
2018-02-01 18:38:13 +00:00
|
|
|
'--issue', issue,
|
|
|
|
'--patchset', patchset,
|
|
|
|
]
|
2018-09-27 18:24:33 +00:00
|
|
|
try:
|
|
|
|
api.step('Trigger and wait for task on android compile server', cmd=cmd)
|
|
|
|
except api.step.StepFailure as e:
|
|
|
|
# Add withpatch and nopatch logs as links (if they exist).
|
2018-12-07 17:32:10 +00:00
|
|
|
gs_file = 'gs://android-compile-tasks/%s-%s-%s.json' % (
|
|
|
|
lunch_target, issue, patchset)
|
2018-09-27 18:24:33 +00:00
|
|
|
step_result = api.step('Get task log links',
|
|
|
|
['gsutil', 'cat', gs_file],
|
|
|
|
stdout=api.json.output())
|
|
|
|
task_json = step_result.stdout
|
|
|
|
if task_json.get('withpatch_log'):
|
|
|
|
api.step.active_result.presentation.links[
|
|
|
|
'withpatch compilation log link'] = task_json['withpatch_log']
|
|
|
|
if task_json.get('nopatch_log'):
|
|
|
|
api.step.active_result.presentation.links[
|
|
|
|
'nopatch compilation log link'] = task_json['nopatch_log']
|
|
|
|
raise e
|
2018-02-01 18:38:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
def GenTests(api):
|
|
|
|
yield(
|
|
|
|
api.test('android_compile_trybot') +
|
|
|
|
api.properties(
|
2018-09-05 17:08:48 +00:00
|
|
|
buildername='Build-Debian9-Clang-cf_x86_phone-eng-Android_Framework',
|
2018-02-01 18:38:13 +00:00
|
|
|
path_config='kitchen',
|
|
|
|
swarm_out_dir='[SWARM_OUT_DIR]',
|
|
|
|
repository='https://skia.googlesource.com/skia.git',
|
|
|
|
patch_issue=1234,
|
|
|
|
patch_set=1,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2018-11-26 17:36:34 +00:00
|
|
|
yield(
|
|
|
|
api.test('android_compile_sdk_trybot') +
|
|
|
|
api.properties(
|
|
|
|
buildername='Build-Debian9-Clang-host-sdk-Android_Framework',
|
|
|
|
path_config='kitchen',
|
|
|
|
swarm_out_dir='[SWARM_OUT_DIR]',
|
|
|
|
repository='https://skia.googlesource.com/skia.git',
|
|
|
|
patch_issue=1234,
|
|
|
|
patch_set=1,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
yield(
|
|
|
|
api.test('android_compile_unrecognized_target') +
|
|
|
|
api.properties(
|
|
|
|
buildername='Build-Debian9-Clang-unrecognized-Android_Framework',
|
|
|
|
path_config='kitchen',
|
|
|
|
swarm_out_dir='[SWARM_OUT_DIR]',
|
|
|
|
repository='https://skia.googlesource.com/skia.git',
|
|
|
|
patch_issue=1234,
|
|
|
|
patch_set=1,
|
|
|
|
) +
|
|
|
|
api.expect_exception('Exception')
|
|
|
|
)
|
|
|
|
|
2018-09-27 18:24:33 +00:00
|
|
|
yield(
|
|
|
|
api.test('android_compile_trybot_failure') +
|
|
|
|
api.properties(
|
|
|
|
buildername='Build-Debian9-Clang-cf_x86_phone-eng-Android_Framework',
|
|
|
|
path_config='kitchen',
|
|
|
|
swarm_out_dir='[SWARM_OUT_DIR]',
|
|
|
|
repository='https://skia.googlesource.com/skia.git',
|
|
|
|
patch_issue=1234,
|
|
|
|
patch_set=1,
|
|
|
|
) +
|
|
|
|
api.step_data('Trigger and wait for task on android compile server',
|
|
|
|
retcode=1) +
|
|
|
|
api.step_data('Get task log links',
|
|
|
|
stdout=api.raw_io.output(
|
|
|
|
'{"withpatch_log":"link1", "nopatch_log":"link2"}'))
|
|
|
|
)
|
|
|
|
|
2018-02-01 18:38:13 +00:00
|
|
|
yield(
|
|
|
|
api.test('android_compile_nontrybot') +
|
|
|
|
api.properties(
|
2018-09-05 17:08:48 +00:00
|
|
|
buildername='Build-Debian9-Clang-cf_x86_phone-eng-Android_Framework',
|
2018-02-01 18:38:13 +00:00
|
|
|
path_config='kitchen',
|
|
|
|
swarm_out_dir='[SWARM_OUT_DIR]',
|
|
|
|
repository='https://skia.googlesource.com/skia.git',
|
|
|
|
revision='abc123',
|
|
|
|
) +
|
|
|
|
api.expect_exception('Exception')
|
|
|
|
)
|