• 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 PathKit 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/perf-karma-chrome-tests:68.0.3440.106_v6'
22INNER_KARMA_SCRIPT = '/SRC/skia/infra/canvaskit/perf_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      '--patch_storage', api.vars.patch_storage,
109    ])
110
111  # Override DOCKER_CONFIG set by Kitchen.
112  env = {'DOCKER_CONFIG': '/home/chrome-bot/.docker'}
113  with api.env(env):
114    api.run(
115        api.step,
116        'Performance tests of canvaskit with Docker',
117        cmd=cmd)
118
119
120def GenTests(api):
121  yield (
122      api.test('Perf-Debian9-EMCC-GCE-CPU-AVX2-wasm-Release-All-CanvasKit') +
123      api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2'
124                                  '-wasm-Release-All-CanvasKit'),
125                     repository='https://skia.googlesource.com/skia.git',
126                     revision='abc123',
127                     path_config='kitchen',
128                     swarm_out_dir='[SWARM_OUT_DIR]')
129  )
130
131  yield (
132      api.test('pathkit_trybot') +
133      api.properties(buildername=('Perf-Debian9-EMCC-GCE-GPU-AVX2'
134                                  '-wasm-Release-All-CanvasKit'),
135                     repository='https://skia.googlesource.com/skia.git',
136                     revision='abc123',
137                     path_config='kitchen',
138                     swarm_out_dir='[SWARM_OUT_DIR]',
139                     patch_ref='89/456789/12',
140                     patch_repo='https://skia.googlesource.com/skia.git',
141                     patch_storage='gerrit',
142                     patch_set=7,
143                     patch_issue=1234,
144                     gerrit_project='skia',
145                     gerrit_url='https://skia-review.googlesource.com/')
146  )
147