blob: d45597b0f41b00af62991e266a9d2e5f32771676 [file] [log] [blame]
Kevin Lubick556350d2018-10-12 15:21:17 -04001# 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',
Ben Wagner325778b2019-01-22 18:09:30 -05009 'env',
Kevin Lubick556350d2018-10-12 15:21:17 -040010 '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
Kevin Lubickd6180272019-03-12 14:06:19 -040021DOCKER_IMAGE = 'gcr.io/skia-public/perf-karma-chrome-tests:72.0.3626.121_v1'
Kevin Lubick556350d2018-10-12 15:21:17 -040022INNER_KARMA_SCRIPT = '/SRC/skia/infra/pathkit/perf_pathkit.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 ./npm-(asmjs|wasm)/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', 'modules', 'pathkit',
37 'npm-wasm', 'bin')
38 if 'asmjs' in api.vars.builder_name:
39 copy_dest = checkout_root.join('skia', 'modules', 'pathkit',
40 'npm-asmjs', 'bin')
41
42 base_dir = api.vars.build_dir
43 bundle_name = 'pathkit.wasm'
44 if 'asmjs' in api.vars.builder_name:
45 bundle_name = 'pathkit.js.mem'
46
47 api.python.inline(
48 name='Set up for docker',
49 program='''import errno
50import os
51import shutil
52import sys
53
54copy_dest = sys.argv[1]
55base_dir = sys.argv[2]
56bundle_name = sys.argv[3]
57out_dir = sys.argv[4]
58
59# Clean out old binaries (if any)
60try:
61 shutil.rmtree(copy_dest)
62except OSError as e:
63 if e.errno != errno.ENOENT:
64 raise
65
66# Make folder
67try:
68 os.makedirs(copy_dest)
69except OSError as e:
70 if e.errno != errno.EEXIST:
71 raise
72
73# Copy binaries (pathkit.js and pathkit.wasm) to where the karma tests
Kevin Lubickf2a146c2018-10-17 14:59:35 -040074# expect them ($SKIA_ROOT/modules/pathkit/npm-wasm/bin/)
Kevin Lubick556350d2018-10-12 15:21:17 -040075dest = os.path.join(copy_dest, 'pathkit.js')
76shutil.copyfile(os.path.join(base_dir, 'pathkit.js'), dest)
77os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
78
79if bundle_name:
80 dest = os.path.join(copy_dest, bundle_name)
81 shutil.copyfile(os.path.join(base_dir, bundle_name), dest)
82 os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
83
84# Prepare output folder, api.file.ensure_directory doesn't touch
85# the permissions of the out directory if it already exists.
86os.chmod(out_dir, 0o777) # important, otherwise non-privileged docker can't write.
87''',
88 args=[copy_dest, base_dir, bundle_name, out_dir],
89 infra_step=True)
90
Kevin Lubick556350d2018-10-12 15:21:17 -040091 cmd = ['docker', 'run', '--shm-size=2gb', '--rm',
Kevin Lubickf2a146c2018-10-17 14:59:35 -040092 '--volume', '%s:/SRC' % checkout_root,
93 '--volume', '%s:/OUT' % out_dir]
Kevin Lubick556350d2018-10-12 15:21:17 -040094
95 if 'asmjs' in api.vars.builder_name:
Kevin Lubickf2a146c2018-10-17 14:59:35 -040096 cmd.extend(['--env', 'ASM_JS=1'])
Kevin Lubick556350d2018-10-12 15:21:17 -040097
98 cmd.extend([
Kevin Lubickf2a146c2018-10-17 14:59:35 -040099 DOCKER_IMAGE, INNER_KARMA_SCRIPT,
100 '--builder', api.vars.builder_name,
101 '--git_hash', api.properties['revision'],
102 '--buildbucket_build_id', api.properties.get('buildbucket_build_id',
103 ''),
104 '--bot_id', api.vars.swarming_bot_id,
105 '--task_id', api.vars.swarming_task_id,
106 '--browser', 'Chrome',
107 '--config', api.vars.configuration,
108 '--source_type', 'pathkit',
109 ])
Kevin Lubick556350d2018-10-12 15:21:17 -0400110
111 if 'asmjs' in api.vars.builder_name:
112 cmd.extend(['--compiled_language', 'asmjs']) # the default is wasm
113
114 if api.vars.is_trybot:
115 cmd.extend([
116 '--issue', api.vars.issue,
117 '--patchset', api.vars.patchset,
118 '--patch_storage', api.vars.patch_storage,
119 ])
120
Ben Wagner325778b2019-01-22 18:09:30 -0500121 # Override DOCKER_CONFIG set by Kitchen.
122 env = {'DOCKER_CONFIG': '/home/chrome-bot/.docker'}
123 with api.env(env):
124 api.run(
125 api.step,
126 'Performance tests of PathKit with Docker',
127 cmd=cmd)
Kevin Lubick556350d2018-10-12 15:21:17 -0400128
129
130def GenTests(api):
131 yield (
132 api.test('Perf-Debian9-EMCC-GCE-CPU-AVX2-wasm-Release-All-PathKit') +
133 api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2'
134 '-wasm-Release-All-PathKit'),
135 repository='https://skia.googlesource.com/skia.git',
136 revision='abc123',
137 path_config='kitchen',
138 swarm_out_dir='[SWARM_OUT_DIR]')
139 )
140
141 yield (
142 api.test('Perf-Debian9-EMCC-GCE-CPU-AVX2-asmjs-Release-All-PathKit') +
143 api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2'
144 '-asmjs-Release-All-PathKit'),
145 repository='https://skia.googlesource.com/skia.git',
146 revision='abc123',
147 path_config='kitchen',
148 swarm_out_dir='[SWARM_OUT_DIR]')
149 )
150
151 yield (
152 api.test('pathkit_trybot') +
153 api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2'
154 '-wasm-Release-All-PathKit'),
155 repository='https://skia.googlesource.com/skia.git',
156 revision='abc123',
157 path_config='kitchen',
158 swarm_out_dir='[SWARM_OUT_DIR]',
159 patch_ref='89/456789/12',
160 patch_repo='https://skia.googlesource.com/skia.git',
161 patch_storage='gerrit',
162 patch_set=7,
163 patch_issue=1234,
164 gerrit_project='skia',
165 gerrit_url='https://skia-review.googlesource.com/')
166 )