blob: 2decbd9741dd78405e1604de8e80e37f53cef8d2 [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
Kevin Lubick92c91712018-08-09 10:00:02 -04005# Recipe which runs the PathKit tests using docker
6
Kevin Lubick92c91712018-08-09 10:00:02 -04007DEPS = [
8 'checkout',
Ben Wagner325778b2019-01-22 18:09:30 -05009 'env',
Kevin Lubick92c91712018-08-09 10:00:02 -040010 'infra',
Kevin Lubick92c91712018-08-09 10:00:02 -040011 '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/gold-karma-chrome-tests:72.0.3626.121_v1'
Kevin Lubick8e9750d2018-10-09 09:36:35 -040022INNER_KARMA_SCRIPT = '/SRC/skia/infra/pathkit/test_pathkit.sh'
Kevin Lubick92c91712018-08-09 10:00:02 -040023
24
Kevin Lubick92c91712018-08-09 10:00:02 -040025def 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.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040032 api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777)
Kevin Lubick92c91712018-08-09 10:00:02 -040033
Kevin Lubickf14a3c02018-08-22 09:35:32 -040034 # The karma script is configured to look in ./npm-(asmjs|wasm)/bin/test/ for
35 # the test files to load, so we must copy them there (see Set up for docker).
Kevin Lubickc7d05712018-08-31 10:03:23 -040036 copy_dest = checkout_root.join('skia', 'modules', 'pathkit',
Kevin Lubick3d99b1e2018-10-16 10:15:01 -040037 'npm-wasm', 'bin', 'test')
Kevin Lubickf14a3c02018-08-22 09:35:32 -040038 if 'asmjs' in api.vars.builder_name:
Kevin Lubickc7d05712018-08-31 10:03:23 -040039 copy_dest = checkout_root.join('skia', 'modules', 'pathkit',
Kevin Lubick3d99b1e2018-10-16 10:15:01 -040040 'npm-asmjs', 'bin', 'test')
Kevin Lubick92c91712018-08-09 10:00:02 -040041
Kevin Lubickf14a3c02018-08-22 09:35:32 -040042 base_dir = api.vars.build_dir
43 bundle_name = 'pathkit.wasm'
44 if 'asmjs' in api.vars.builder_name:
45 # release mode has a .js.mem file that needs to come with.
46 # debug mode has an optional .map file, but we can omit that for tests
47 if 'Debug' in api.vars.builder_name:
48 bundle_name = ''
49 else:
50 bundle_name = 'pathkit.js.mem'
Kevin Lubick92c91712018-08-09 10:00:02 -040051
52 api.python.inline(
Kevin Lubicka0ba6122018-08-15 13:45:28 -040053 name='Set up for docker',
Kevin Lubick92c91712018-08-09 10:00:02 -040054 program='''import errno
55import os
56import shutil
57import sys
58
59copy_dest = sys.argv[1]
Kevin Lubickf14a3c02018-08-22 09:35:32 -040060base_dir = sys.argv[2]
61bundle_name = sys.argv[3]
Kevin Lubicka0ba6122018-08-15 13:45:28 -040062out_dir = sys.argv[4]
Kevin Lubick92c91712018-08-09 10:00:02 -040063
64# Clean out old binaries (if any)
65try:
66 shutil.rmtree(copy_dest)
67except OSError as e:
68 if e.errno != errno.ENOENT:
69 raise
70
71# Make folder
72try:
73 os.makedirs(copy_dest)
74except OSError as e:
75 if e.errno != errno.EEXIST:
76 raise
77
Kevin Lubicka0ba6122018-08-15 13:45:28 -040078# Copy binaries (pathkit.js and pathkit.wasm) to where the karma tests
Kevin Lubick3d99b1e2018-10-16 10:15:01 -040079# expect them ($SKIA_ROOT/modules/pathkit/npm-wasm/bin/test/)
Kevin Lubick92c91712018-08-09 10:00:02 -040080dest = os.path.join(copy_dest, 'pathkit.js')
Kevin Lubickf14a3c02018-08-22 09:35:32 -040081shutil.copyfile(os.path.join(base_dir, 'pathkit.js'), dest)
Kevin Lubick92c91712018-08-09 10:00:02 -040082os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
83
Kevin Lubickf14a3c02018-08-22 09:35:32 -040084if bundle_name:
85 dest = os.path.join(copy_dest, bundle_name)
86 shutil.copyfile(os.path.join(base_dir, bundle_name), dest)
87 os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040088
Kevin Lubick82999c02018-08-28 10:52:18 -040089# Prepare output folder, api.file.ensure_directory doesn't touch
90# the permissions of the out directory if it already exists.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040091os.chmod(out_dir, 0o777) # important, otherwise non-privileged docker can't write.
Kevin Lubick92c91712018-08-09 10:00:02 -040092''',
Kevin Lubickf14a3c02018-08-22 09:35:32 -040093 args=[copy_dest, base_dir, bundle_name, out_dir],
Kevin Lubick92c91712018-08-09 10:00:02 -040094 infra_step=True)
95
Kevin Lubicka0ba6122018-08-15 13:45:28 -040096
Kevin Lubick92c91712018-08-09 10:00:02 -040097 cmd = ['docker', 'run', '--shm-size=2gb', '--rm',
Kevin Lubick3d99b1e2018-10-16 10:15:01 -040098 '--volume', '%s:/SRC' % checkout_root,
99 '--volume', '%s:/OUT' % out_dir]
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400100
101 if 'asmjs' in api.vars.builder_name:
Kevin Lubick3d99b1e2018-10-16 10:15:01 -0400102 cmd.extend(['--env', 'ASM_JS=1'])
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400103
104 cmd.extend([
Kevin Lubick3d99b1e2018-10-16 10:15:01 -0400105 DOCKER_IMAGE, INNER_KARMA_SCRIPT,
106 '--builder', api.vars.builder_name,
107 '--git_hash', api.properties['revision'],
108 '--buildbucket_build_id', api.properties.get('buildbucket_build_id',
109 ''),
110 '--bot_id', api.vars.swarming_bot_id,
111 '--task_id', api.vars.swarming_task_id,
112 '--browser', 'Chrome',
113 '--config', api.vars.configuration,
114 '--source_type', 'pathkit',
115 ])
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400116
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,
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400124 ])
Kevin Lubick92c91712018-08-09 10:00:02 -0400125
Ben Wagner325778b2019-01-22 18:09:30 -0500126 # Override DOCKER_CONFIG set by Kitchen.
127 env = {'DOCKER_CONFIG': '/home/chrome-bot/.docker'}
128 with api.env(env):
129 api.run(
130 api.step,
131 'Test PathKit with Docker',
132 cmd=cmd)
Kevin Lubick92c91712018-08-09 10:00:02 -0400133
134
135def GenTests(api):
136 yield (
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400137 api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-wasm-Debug-All-PathKit') +
Kevin Lubick92c91712018-08-09 10:00:02 -0400138 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
139 '-wasm-Debug-All-PathKit'),
140 repository='https://skia.googlesource.com/skia.git',
141 revision='abc123',
142 path_config='kitchen',
143 swarm_out_dir='[SWARM_OUT_DIR]')
144 )
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400145
146 yield (
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400147 api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-asmjs-Debug-All-PathKit') +
148 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
149 '-asmjs-Debug-All-PathKit'),
150 repository='https://skia.googlesource.com/skia.git',
151 revision='abc123',
152 path_config='kitchen',
153 swarm_out_dir='[SWARM_OUT_DIR]')
154 )
155
156 yield (
157 api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-asmjs-Release-All-PathKit') +
158 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
159 '-asmjs-Release-All-PathKit'),
160 repository='https://skia.googlesource.com/skia.git',
161 revision='abc123',
162 path_config='kitchen',
163 swarm_out_dir='[SWARM_OUT_DIR]')
164 )
165
166 yield (
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400167 api.test('pathkit_trybot') +
168 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
169 '-wasm-Debug-All-PathKit'),
170 repository='https://skia.googlesource.com/skia.git',
171 revision='abc123',
172 path_config='kitchen',
173 swarm_out_dir='[SWARM_OUT_DIR]',
Eric Boren858f6482018-09-12 14:39:34 -0400174 patch_ref='89/456789/12',
175 patch_repo='https://skia.googlesource.com/skia.git',
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400176 patch_storage='gerrit',
177 patch_set=7,
178 patch_issue=1234,
179 gerrit_project='skia',
180 gerrit_url='https://skia-review.googlesource.com/')
181 )