blob: aa42068f21b1059bcc80389b509e0e7de9cb6cb9 [file] [log] [blame]
Kevin Lubick92c91712018-08-09 10:00:02 -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
6# Recipe which runs the PathKit tests using docker
7
8
9DEPS = [
10 'checkout',
11 'infra',
Kevin Lubick92c91712018-08-09 10:00:02 -040012 'recipe_engine/file',
13 'recipe_engine/path',
14 'recipe_engine/properties',
15 'recipe_engine/python',
16 'recipe_engine/step',
17 'run',
18 'vars',
19]
20
21
Kevin Lubickf14a3c02018-08-22 09:35:32 -040022DOCKER_IMAGE = 'gcr.io/skia-public/gold-karma-chrome-tests:68.0.3440.106_v4'
Kevin Lubicka0ba6122018-08-15 13:45:28 -040023INNER_KARMA_SCRIPT = '/SRC/skia/infra/pathkit/docker/test_pathkit.sh'
Kevin Lubick92c91712018-08-09 10:00:02 -040024
25
26
27def RunSteps(api):
28 api.vars.setup()
29 checkout_root = api.checkout.default_checkout_root
30 out_dir = api.vars.swarming_out_dir
31 api.checkout.bot_update(checkout_root=checkout_root)
32
33 # Make sure this exists, otherwise Docker will make it with root permissions.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040034 api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777)
Kevin Lubick92c91712018-08-09 10:00:02 -040035
Kevin Lubickf14a3c02018-08-22 09:35:32 -040036 # The karma script is configured to look in ./npm-(asmjs|wasm)/bin/test/ for
37 # the test files to load, so we must copy them there (see Set up for docker).
38 copy_dest = checkout_root.join('skia', 'experimental', 'pathkit',
Kevin Lubick92c91712018-08-09 10:00:02 -040039 'npm-wasm', 'bin', 'test')
Kevin Lubickf14a3c02018-08-22 09:35:32 -040040 if 'asmjs' in api.vars.builder_name:
41 copy_dest = checkout_root.join('skia', 'experimental', 'pathkit',
42 'npm-asmjs', 'bin', 'test')
Kevin Lubick92c91712018-08-09 10:00:02 -040043
Kevin Lubickf14a3c02018-08-22 09:35:32 -040044 base_dir = api.vars.build_dir
45 bundle_name = 'pathkit.wasm'
46 if 'asmjs' in api.vars.builder_name:
47 # release mode has a .js.mem file that needs to come with.
48 # debug mode has an optional .map file, but we can omit that for tests
49 if 'Debug' in api.vars.builder_name:
50 bundle_name = ''
51 else:
52 bundle_name = 'pathkit.js.mem'
Kevin Lubick92c91712018-08-09 10:00:02 -040053
54 api.python.inline(
Kevin Lubicka0ba6122018-08-15 13:45:28 -040055 name='Set up for docker',
Kevin Lubick92c91712018-08-09 10:00:02 -040056 program='''import errno
57import os
58import shutil
59import sys
60
61copy_dest = sys.argv[1]
Kevin Lubickf14a3c02018-08-22 09:35:32 -040062base_dir = sys.argv[2]
63bundle_name = sys.argv[3]
Kevin Lubicka0ba6122018-08-15 13:45:28 -040064out_dir = sys.argv[4]
Kevin Lubick92c91712018-08-09 10:00:02 -040065
66# Clean out old binaries (if any)
67try:
68 shutil.rmtree(copy_dest)
69except OSError as e:
70 if e.errno != errno.ENOENT:
71 raise
72
73# Make folder
74try:
75 os.makedirs(copy_dest)
76except OSError as e:
77 if e.errno != errno.EEXIST:
78 raise
79
Kevin Lubicka0ba6122018-08-15 13:45:28 -040080# Copy binaries (pathkit.js and pathkit.wasm) to where the karma tests
81# expect them ($SKIA_ROOT/experimental/pathkit/npm-wasm/test/)
Kevin Lubick92c91712018-08-09 10:00:02 -040082dest = os.path.join(copy_dest, 'pathkit.js')
Kevin Lubickf14a3c02018-08-22 09:35:32 -040083shutil.copyfile(os.path.join(base_dir, 'pathkit.js'), dest)
Kevin Lubick92c91712018-08-09 10:00:02 -040084os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
85
Kevin Lubickf14a3c02018-08-22 09:35:32 -040086if bundle_name:
87 dest = os.path.join(copy_dest, bundle_name)
88 shutil.copyfile(os.path.join(base_dir, bundle_name), dest)
89 os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040090
91# Prepare output folder
92os.chmod(out_dir, 0o777) # important, otherwise non-privileged docker can't write.
Kevin Lubick92c91712018-08-09 10:00:02 -040093''',
Kevin Lubickf14a3c02018-08-22 09:35:32 -040094 args=[copy_dest, base_dir, bundle_name, out_dir],
Kevin Lubick92c91712018-08-09 10:00:02 -040095 infra_step=True)
96
Kevin Lubicka0ba6122018-08-15 13:45:28 -040097
Kevin Lubick92c91712018-08-09 10:00:02 -040098
99 cmd = ['docker', 'run', '--shm-size=2gb', '--rm',
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400100 '-v', '%s:/SRC' % checkout_root, '-v', '%s:/OUT' % out_dir]
101
102 if 'asmjs' in api.vars.builder_name:
103 cmd.extend(['-e', 'ASM_JS=1']) # -e sets environment variables
104
105 cmd.extend([
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400106 DOCKER_IMAGE, INNER_KARMA_SCRIPT,
107 '--builder', api.vars.builder_name,
108 '--git_hash', api.properties['revision'],
109 '--buildbucket_build_id', api.properties.get('buildbucket_build_id',
110 ''),
111 '--bot_id', api.vars.swarming_bot_id,
112 '--task_id', api.vars.swarming_task_id,
113 '--browser', 'Chrome',
114 '--config', api.vars.configuration,
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400115 ])
116
117 if 'asmjs' in api.vars.builder_name:
118 cmd.extend(['--compiled_language', 'asmjs']) # the default is wasm
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400119
120 if api.vars.is_trybot:
121 cmd.extend([
122 '--issue', api.vars.issue,
123 '--patchset', api.vars.patchset,
124 '--patch_storage', api.vars.patch_storage,
125 ])
Kevin Lubick92c91712018-08-09 10:00:02 -0400126
127 api.run(
128 api.step,
129 'Test PathKit with Docker',
130 cmd=cmd)
131
132
133def GenTests(api):
134 yield (
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400135 api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-wasm-Debug-All-PathKit') +
Kevin Lubick92c91712018-08-09 10:00:02 -0400136 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
137 '-wasm-Debug-All-PathKit'),
138 repository='https://skia.googlesource.com/skia.git',
139 revision='abc123',
140 path_config='kitchen',
141 swarm_out_dir='[SWARM_OUT_DIR]')
142 )
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400143
144 yield (
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400145 api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-asmjs-Debug-All-PathKit') +
146 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
147 '-asmjs-Debug-All-PathKit'),
148 repository='https://skia.googlesource.com/skia.git',
149 revision='abc123',
150 path_config='kitchen',
151 swarm_out_dir='[SWARM_OUT_DIR]')
152 )
153
154 yield (
155 api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-asmjs-Release-All-PathKit') +
156 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
157 '-asmjs-Release-All-PathKit'),
158 repository='https://skia.googlesource.com/skia.git',
159 revision='abc123',
160 path_config='kitchen',
161 swarm_out_dir='[SWARM_OUT_DIR]')
162 )
163
164 yield (
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400165 api.test('pathkit_trybot') +
166 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
167 '-wasm-Debug-All-PathKit'),
168 repository='https://skia.googlesource.com/skia.git',
169 revision='abc123',
170 path_config='kitchen',
171 swarm_out_dir='[SWARM_OUT_DIR]',
172 patch_storage='gerrit',
173 patch_set=7,
174 patch_issue=1234,
175 gerrit_project='skia',
176 gerrit_url='https://skia-review.googlesource.com/')
177 )