blob: 3ed789fb8ddfecc8b6abe1ed271f56aec5ec6457 [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',
9 'infra',
Kevin Lubick92c91712018-08-09 10:00:02 -040010 '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 Lubickf14a3c02018-08-22 09:35:32 -040020DOCKER_IMAGE = 'gcr.io/skia-public/gold-karma-chrome-tests:68.0.3440.106_v4'
Kevin Lubick8e9750d2018-10-09 09:36:35 -040021INNER_KARMA_SCRIPT = '/SRC/skia/infra/pathkit/test_pathkit.sh'
Kevin Lubick92c91712018-08-09 10:00:02 -040022
23
Kevin Lubick92c91712018-08-09 10:00:02 -040024def 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.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040031 api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777)
Kevin Lubick92c91712018-08-09 10:00:02 -040032
Kevin Lubickf14a3c02018-08-22 09:35:32 -040033 # The karma script is configured to look in ./npm-(asmjs|wasm)/bin/test/ for
34 # the test files to load, so we must copy them there (see Set up for docker).
Kevin Lubickc7d05712018-08-31 10:03:23 -040035 copy_dest = checkout_root.join('skia', 'modules', 'pathkit',
Kevin Lubick92c91712018-08-09 10:00:02 -040036 'npm-wasm', 'bin', 'test')
Kevin Lubickf14a3c02018-08-22 09:35:32 -040037 if 'asmjs' in api.vars.builder_name:
Kevin Lubickc7d05712018-08-31 10:03:23 -040038 copy_dest = checkout_root.join('skia', 'modules', 'pathkit',
Kevin Lubickf14a3c02018-08-22 09:35:32 -040039 'npm-asmjs', 'bin', 'test')
Kevin Lubick92c91712018-08-09 10:00:02 -040040
Kevin Lubickf14a3c02018-08-22 09:35:32 -040041 base_dir = api.vars.build_dir
42 bundle_name = 'pathkit.wasm'
43 if 'asmjs' in api.vars.builder_name:
44 # release mode has a .js.mem file that needs to come with.
45 # debug mode has an optional .map file, but we can omit that for tests
46 if 'Debug' in api.vars.builder_name:
47 bundle_name = ''
48 else:
49 bundle_name = 'pathkit.js.mem'
Kevin Lubick92c91712018-08-09 10:00:02 -040050
51 api.python.inline(
Kevin Lubicka0ba6122018-08-15 13:45:28 -040052 name='Set up for docker',
Kevin Lubick92c91712018-08-09 10:00:02 -040053 program='''import errno
54import os
55import shutil
56import sys
57
58copy_dest = sys.argv[1]
Kevin Lubickf14a3c02018-08-22 09:35:32 -040059base_dir = sys.argv[2]
60bundle_name = sys.argv[3]
Kevin Lubicka0ba6122018-08-15 13:45:28 -040061out_dir = sys.argv[4]
Kevin Lubick92c91712018-08-09 10:00:02 -040062
63# Clean out old binaries (if any)
64try:
65 shutil.rmtree(copy_dest)
66except OSError as e:
67 if e.errno != errno.ENOENT:
68 raise
69
70# Make folder
71try:
72 os.makedirs(copy_dest)
73except OSError as e:
74 if e.errno != errno.EEXIST:
75 raise
76
Kevin Lubicka0ba6122018-08-15 13:45:28 -040077# Copy binaries (pathkit.js and pathkit.wasm) to where the karma tests
Kevin Lubickc7d05712018-08-31 10:03:23 -040078# expect them ($SKIA_ROOT/modules/pathkit/npm-wasm/test/)
Kevin Lubick92c91712018-08-09 10:00:02 -040079dest = os.path.join(copy_dest, 'pathkit.js')
Kevin Lubickf14a3c02018-08-22 09:35:32 -040080shutil.copyfile(os.path.join(base_dir, 'pathkit.js'), dest)
Kevin Lubick92c91712018-08-09 10:00:02 -040081os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
82
Kevin Lubickf14a3c02018-08-22 09:35:32 -040083if bundle_name:
84 dest = os.path.join(copy_dest, bundle_name)
85 shutil.copyfile(os.path.join(base_dir, bundle_name), dest)
86 os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040087
Kevin Lubick82999c02018-08-28 10:52:18 -040088# Prepare output folder, api.file.ensure_directory doesn't touch
89# the permissions of the out directory if it already exists.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040090os.chmod(out_dir, 0o777) # important, otherwise non-privileged docker can't write.
Kevin Lubick92c91712018-08-09 10:00:02 -040091''',
Kevin Lubickf14a3c02018-08-22 09:35:32 -040092 args=[copy_dest, base_dir, bundle_name, out_dir],
Kevin Lubick92c91712018-08-09 10:00:02 -040093 infra_step=True)
94
Kevin Lubicka0ba6122018-08-15 13:45:28 -040095
Kevin Lubick92c91712018-08-09 10:00:02 -040096
97 cmd = ['docker', 'run', '--shm-size=2gb', '--rm',
Kevin Lubickf14a3c02018-08-22 09:35:32 -040098 '-v', '%s:/SRC' % checkout_root, '-v', '%s:/OUT' % out_dir]
99
100 if 'asmjs' in api.vars.builder_name:
101 cmd.extend(['-e', 'ASM_JS=1']) # -e sets environment variables
102
103 cmd.extend([
Kevin Lubick82999c02018-08-28 10:52:18 -0400104 DOCKER_IMAGE, INNER_KARMA_SCRIPT,
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400105 '--builder', api.vars.builder_name,
106 '--git_hash', api.properties['revision'],
107 '--buildbucket_build_id', api.properties.get('buildbucket_build_id',
108 ''),
109 '--bot_id', api.vars.swarming_bot_id,
110 '--task_id', api.vars.swarming_task_id,
111 '--browser', 'Chrome',
112 '--config', api.vars.configuration,
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400113 ])
114
115 if 'asmjs' in api.vars.builder_name:
116 cmd.extend(['--compiled_language', 'asmjs']) # the default is wasm
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400117
118 if api.vars.is_trybot:
119 cmd.extend([
120 '--issue', api.vars.issue,
121 '--patchset', api.vars.patchset,
122 '--patch_storage', api.vars.patch_storage,
123 ])
Kevin Lubick92c91712018-08-09 10:00:02 -0400124
125 api.run(
126 api.step,
127 'Test PathKit with Docker',
128 cmd=cmd)
129
130
131def GenTests(api):
132 yield (
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400133 api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-wasm-Debug-All-PathKit') +
Kevin Lubick92c91712018-08-09 10:00:02 -0400134 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
135 '-wasm-Debug-All-PathKit'),
136 repository='https://skia.googlesource.com/skia.git',
137 revision='abc123',
138 path_config='kitchen',
139 swarm_out_dir='[SWARM_OUT_DIR]')
140 )
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400141
142 yield (
Kevin Lubickf14a3c02018-08-22 09:35:32 -0400143 api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-asmjs-Debug-All-PathKit') +
144 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
145 '-asmjs-Debug-All-PathKit'),
146 repository='https://skia.googlesource.com/skia.git',
147 revision='abc123',
148 path_config='kitchen',
149 swarm_out_dir='[SWARM_OUT_DIR]')
150 )
151
152 yield (
153 api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-asmjs-Release-All-PathKit') +
154 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
155 '-asmjs-Release-All-PathKit'),
156 repository='https://skia.googlesource.com/skia.git',
157 revision='abc123',
158 path_config='kitchen',
159 swarm_out_dir='[SWARM_OUT_DIR]')
160 )
161
162 yield (
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400163 api.test('pathkit_trybot') +
164 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
165 '-wasm-Debug-All-PathKit'),
166 repository='https://skia.googlesource.com/skia.git',
167 revision='abc123',
168 path_config='kitchen',
169 swarm_out_dir='[SWARM_OUT_DIR]',
Eric Boren858f6482018-09-12 14:39:34 -0400170 patch_ref='89/456789/12',
171 patch_repo='https://skia.googlesource.com/skia.git',
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400172 patch_storage='gerrit',
173 patch_set=7,
174 patch_issue=1234,
175 gerrit_project='skia',
176 gerrit_url='https://skia-review.googlesource.com/')
177 )