1# Copyright 2018 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
6import math
7
8
9DEPS = [
10  'recipe_engine/properties',
11  'recipe_engine/step',
12  'vars',
13]
14
15
16def RunSteps(api):
17  api.vars.setup()
18
19  buildername = api.properties['buildername']
20  issue = api.properties.get('patch_issue')
21  patchset = api.properties.get('patch_set')
22  if not issue or not patchset:
23    # This bot currently only supports trybot runs because:
24    # Non-trybot runs could fail if the Android tree is red. We mitigate this
25    # for trybot runs by verifying that runs without the patch succeed. We do
26    # not currently have a way to do the same for non-trybot runs.
27    raise Exception('%s can only be run as a trybot.' % buildername)
28
29  infrabots_dir = api.vars.skia_dir.join('infra', 'bots')
30  trigger_wait_ac_script = infrabots_dir.join('android_compile',
31                                              'trigger_wait_ac_task.py')
32
33  # Trigger a compile task on android-compile.skia.org and wait for it to
34  # complete.
35  cmd = ['python', trigger_wait_ac_script,
36         '--issue', issue,
37         '--patchset', patchset,
38        ]
39  api.step('Trigger and wait for task on android-compile.skia.org', cmd=cmd)
40
41
42def GenTests(api):
43  yield(
44    api.test('android_compile_trybot') +
45    api.properties(
46        buildername='Build-Debian9-Clang-gce_x86_phone-eng-Android_Framework',
47        path_config='kitchen',
48        swarm_out_dir='[SWARM_OUT_DIR]',
49        repository='https://skia.googlesource.com/skia.git',
50        patch_issue=1234,
51        patch_set=1,
52    )
53  )
54
55  yield(
56    api.test('android_compile_nontrybot') +
57    api.properties(
58        buildername='Build-Debian9-Clang-gce_x86_phone-eng-Android_Framework',
59        path_config='kitchen',
60        swarm_out_dir='[SWARM_OUT_DIR]',
61        repository='https://skia.googlesource.com/skia.git',
62        revision='abc123',
63    ) +
64    api.expect_exception('Exception')
65  )
66