blob: ba1ea93061f6131e9ffbdee6228caff4207ab97d [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',
9 'infra',
10 'recipe_engine/file',
11 'recipe_engine/path',
12 'recipe_engine/properties',
13 'recipe_engine/python',
14 'recipe_engine/step',
15 'run',
16 'vars',
17]
18
19
Kevin Lubick3d99b1e2018-10-16 10:15:01 -040020DOCKER_IMAGE = 'gcr.io/skia-public/perf-karma-chrome-tests:68.0.3440.106_v6'
Kevin Lubick556350d2018-10-12 15:21:17 -040021INNER_KARMA_SCRIPT = '/SRC/skia/infra/pathkit/perf_pathkit.sh'
22
23
24def RunSteps(api):
25 api.vars.setup()
26 checkout_root = api.checkout.default_checkout_root
27 out_dir = api.vars.swarming_out_dir
28 api.checkout.bot_update(checkout_root=checkout_root)
29
30 # Make sure this exists, otherwise Docker will make it with root permissions.
31 api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777)
32
33 # The karma script is configured to look in ./npm-(asmjs|wasm)/bin/ for
34 # the test files to load, so we must copy them there (see Set up for docker).
35 copy_dest = checkout_root.join('skia', 'modules', 'pathkit',
36 'npm-wasm', 'bin')
37 if 'asmjs' in api.vars.builder_name:
38 copy_dest = checkout_root.join('skia', 'modules', 'pathkit',
39 'npm-asmjs', 'bin')
40
41 base_dir = api.vars.build_dir
42 bundle_name = 'pathkit.wasm'
43 if 'asmjs' in api.vars.builder_name:
44 bundle_name = 'pathkit.js.mem'
45
46 api.python.inline(
47 name='Set up for docker',
48 program='''import errno
49import os
50import shutil
51import sys
52
53copy_dest = sys.argv[1]
54base_dir = sys.argv[2]
55bundle_name = sys.argv[3]
56out_dir = sys.argv[4]
57
58# Clean out old binaries (if any)
59try:
60 shutil.rmtree(copy_dest)
61except OSError as e:
62 if e.errno != errno.ENOENT:
63 raise
64
65# Make folder
66try:
67 os.makedirs(copy_dest)
68except OSError as e:
69 if e.errno != errno.EEXIST:
70 raise
71
72# Copy binaries (pathkit.js and pathkit.wasm) to where the karma tests
73# expect them ($SKIA_ROOT/modules/pathkit/npm-wasm/)
74dest = os.path.join(copy_dest, 'pathkit.js')
75shutil.copyfile(os.path.join(base_dir, 'pathkit.js'), dest)
76os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
77
78if bundle_name:
79 dest = os.path.join(copy_dest, bundle_name)
80 shutil.copyfile(os.path.join(base_dir, bundle_name), dest)
81 os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
82
83# Prepare output folder, api.file.ensure_directory doesn't touch
84# the permissions of the out directory if it already exists.
85os.chmod(out_dir, 0o777) # important, otherwise non-privileged docker can't write.
86''',
87 args=[copy_dest, base_dir, bundle_name, out_dir],
88 infra_step=True)
89
90
91
92 cmd = ['docker', 'run', '--shm-size=2gb', '--rm',
93 '-v', '%s:/SRC' % checkout_root, '-v', '%s:/OUT' % out_dir]
94
95 if 'asmjs' in api.vars.builder_name:
96 cmd.extend(['-e', 'ASM_JS=1']) # -e sets environment variables
97
98 cmd.extend([
99 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,
Kevin Lubick3d99b1e2018-10-16 10:15:01 -0400108 '--source_type', 'pathkit',
Kevin Lubick556350d2018-10-12 15:21:17 -0400109 ])
110
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
121 api.run(
122 api.step,
123 'Performance tests of PathKit with Docker',
124 cmd=cmd)
125
126
127def GenTests(api):
128 yield (
129 api.test('Perf-Debian9-EMCC-GCE-CPU-AVX2-wasm-Release-All-PathKit') +
130 api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2'
131 '-wasm-Release-All-PathKit'),
132 repository='https://skia.googlesource.com/skia.git',
133 revision='abc123',
134 path_config='kitchen',
135 swarm_out_dir='[SWARM_OUT_DIR]')
136 )
137
138 yield (
139 api.test('Perf-Debian9-EMCC-GCE-CPU-AVX2-asmjs-Release-All-PathKit') +
140 api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2'
141 '-asmjs-Release-All-PathKit'),
142 repository='https://skia.googlesource.com/skia.git',
143 revision='abc123',
144 path_config='kitchen',
145 swarm_out_dir='[SWARM_OUT_DIR]')
146 )
147
148 yield (
149 api.test('pathkit_trybot') +
150 api.properties(buildername=('Perf-Debian9-EMCC-GCE-CPU-AVX2'
151 '-wasm-Release-All-PathKit'),
152 repository='https://skia.googlesource.com/skia.git',
153 revision='abc123',
154 path_config='kitchen',
155 swarm_out_dir='[SWARM_OUT_DIR]',
156 patch_ref='89/456789/12',
157 patch_repo='https://skia.googlesource.com/skia.git',
158 patch_storage='gerrit',
159 patch_set=7,
160 patch_issue=1234,
161 gerrit_project='skia',
162 gerrit_url='https://skia-review.googlesource.com/')
163 )