• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 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
6DEPS = [
7  'recipe_engine/file',
8  'recipe_engine/json',
9  'recipe_engine/path',
10  'recipe_engine/properties',
11  'recipe_engine/raw_io',
12  'recipe_engine/step',
13  'recipe_engine/tempfile',
14]
15
16
17def RunSteps(api):
18  buildername = api.properties['buildername']
19  issue = api.properties.get('patch_issue')
20  patchset = api.properties.get('patch_set')
21  if not issue or not patchset:
22    raise Exception('%s can only be run as a trybot.' % buildername)
23
24  infrabots_dir = api.path['start_dir'].join('skia', 'infra', 'bots')
25  trigger_wait_g3_script = infrabots_dir.join('g3_compile',
26                                              'trigger_wait_g3_task.py')
27
28  with api.tempfile.temp_dir('g3_try') as output_dir:
29    output_file = output_dir.join('output_file')
30    # Trigger a compile task and wait for it to complete.
31    cmd = ['python', trigger_wait_g3_script,
32           '--issue', issue,
33           '--patchset', patchset,
34           '--output_file', output_file,
35          ]
36    try:
37      api.step('Trigger and wait for g3 compile task', cmd=cmd)
38    except api.step.StepFailure as e:
39      # Add CL link if it exists in the output_file.
40      task_json = api.file.read_json(
41          'Read task json', output_file, test_data={'cl': 12345})
42      if task_json.get('cl'):
43        api.step.active_result.presentation.links['CL link'] = (
44            'http://cl/%d' % task_json['cl'])
45      raise e
46
47
48def GenTests(api):
49  yield(
50    api.test('g3_compile_trybot') +
51    api.properties(
52        buildername='Build-Debian9-Clang-TAP-Presubmit-G3_Framework',
53        path_config='kitchen',
54        swarm_out_dir='[SWARM_OUT_DIR]',
55        repository='https://skia.googlesource.com/skia.git',
56        patch_issue=1234,
57        patch_set=1,
58        revision='abc123',
59    )
60  )
61
62  yield(
63    api.test('g3_compile_trybot_failure') +
64    api.properties(
65        buildername='Build-Debian9-Clang-TAP-Presubmit-G3_Framework',
66        path_config='kitchen',
67        swarm_out_dir='[SWARM_OUT_DIR]',
68        repository='https://skia.googlesource.com/skia.git',
69        patch_issue=1234,
70        patch_set=1,
71        revision='abc123',
72    ) +
73    api.step_data('Trigger and wait for g3 compile task', retcode=1)
74  )
75
76  yield(
77    api.test('g3_compile_nontrybot') +
78    api.properties(
79        buildername='Build-Debian9-Clang-TAP-Presubmit-G3_Framework',
80        path_config='kitchen',
81        swarm_out_dir='[SWARM_OUT_DIR]',
82        repository='https://skia.googlesource.com/skia.git',
83        revision='abc123',
84    ) +
85    api.expect_exception('Exception')
86  )
87