• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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# Recipe which runs the Canvaskit tests using docker
6
7DEPS = [
8  'checkout',
9  'env',
10  'infra',
11  'recipe_engine/file',
12  'recipe_engine/path',
13  'recipe_engine/properties',
14  'recipe_engine/python',
15  'recipe_engine/step',
16  'run',
17  'vars',
18]
19
20
21DOCKER_IMAGE = 'gcr.io/skia-public/gold-karma-chrome-tests:68.0.3440.106_v6'
22INNER_KARMA_SCRIPT = '/SRC/skia/infra/canvaskit/test_canvaskit.sh'
23
24
25def RunSteps(api):
26  api.vars.setup()
27  checkout_root = api.checkout.default_checkout_root
28  out_dir = api.vars.swarming_out_dir
29  api.checkout.bot_update(checkout_root=checkout_root)
30
31  # Make sure this exists, otherwise Docker will make it with root permissions.
32  api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777)
33
34  # The karma script is configured to look in ./canvaskit/bin/ for
35  # the test files to load, so we must copy them there (see Set up for docker).
36  copy_dest = checkout_root.join('skia', 'experimental', 'canvaskit',
37                                 'canvaskit', 'bin')
38
39  base_dir = api.vars.build_dir
40  bundle_name = 'canvaskit.wasm'
41
42  api.python.inline(
43      name='Set up for docker',
44      program='''import errno
45import os
46import shutil
47import sys
48
49copy_dest = sys.argv[1]
50base_dir = sys.argv[2]
51bundle_name = sys.argv[3]
52out_dir = sys.argv[4]
53
54# Clean out old binaries (if any)
55try:
56  shutil.rmtree(copy_dest)
57except OSError as e:
58  if e.errno != errno.ENOENT:
59    raise
60
61# Make folder
62try:
63  os.makedirs(copy_dest)
64except OSError as e:
65  if e.errno != errno.EEXIST:
66    raise
67
68# Copy binaries (canvaskit.js and canvaskit.wasm) to where the karma tests
69# expect them ($SKIA_ROOT/experimental/canvaskit/canvaskit/bin/)
70dest = os.path.join(copy_dest, 'canvaskit.js')
71shutil.copyfile(os.path.join(base_dir, 'canvaskit.js'), dest)
72os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
73
74if bundle_name:
75  dest = os.path.join(copy_dest, bundle_name)
76  shutil.copyfile(os.path.join(base_dir, bundle_name), dest)
77  os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
78
79# Prepare output folder, api.file.ensure_directory doesn't touch
80# the permissions of the out directory if it already exists.
81os.chmod(out_dir, 0o777) # important, otherwise non-privileged docker can't write.
82''',
83      args=[copy_dest, base_dir, bundle_name, out_dir],
84      infra_step=True)
85
86
87  cmd = ['docker', 'run', '--shm-size=2gb', '--rm',
88         '--volume', '%s:/SRC' % checkout_root,
89         '--volume', '%s:/OUT' % out_dir]
90
91  cmd.extend([
92      DOCKER_IMAGE,             INNER_KARMA_SCRIPT,
93      '--builder',              api.vars.builder_name,
94      '--git_hash',             api.properties['revision'],
95      '--buildbucket_build_id', api.properties.get('buildbucket_build_id',
96                                                  ''),
97      '--bot_id',               api.vars.swarming_bot_id,
98      '--task_id',              api.vars.swarming_task_id,
99      '--browser',              'Chrome',
100      '--config',               api.vars.configuration,
101      '--source_type',          'canvaskit',
102      ])
103
104  if api.vars.is_trybot:
105    cmd.extend([
106      '--issue',         api.vars.issue,
107      '--patchset',      api.vars.patchset,
108    ])
109
110  # Override DOCKER_CONFIG set by Kitchen.
111  env = {'DOCKER_CONFIG': '/home/chrome-bot/.docker'}
112  with api.env(env):
113    api.run(
114        api.step,
115        'Test CanvasKit with Docker',
116        cmd=cmd)
117
118
119def GenTests(api):
120  yield (
121      api.test('Test-Debian9-EMCC-GCE-GPU-WEBGL1-wasm-Debug-All-CanvasKit') +
122      api.properties(buildername=('Test-Debian9-EMCC-GCE-GPU-WEBGL1'
123                                  '-wasm-Debug-All-CanvasKit'),
124                     repository='https://skia.googlesource.com/skia.git',
125                     revision='abc123',
126                     path_config='kitchen',
127                     swarm_out_dir='[SWARM_OUT_DIR]')
128  )
129
130  yield (
131      api.test('canvaskit_trybot') +
132      api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
133                                  '-wasm-Debug-All-CanvasKit'),
134                     repository='https://skia.googlesource.com/skia.git',
135                     revision='abc123',
136                     path_config='kitchen',
137                     swarm_out_dir='[SWARM_OUT_DIR]',
138                     patch_ref='89/456789/12',
139                     patch_repo='https://skia.googlesource.com/skia.git',
140                     patch_storage='gerrit',
141                     patch_set=7,
142                     patch_issue=1234,
143                     gerrit_project='skia',
144                     gerrit_url='https://skia-review.googlesource.com/')
145  )
146