blob: c620ce5312ebdfc712e6c77a0b340aed5a307eb5 [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',
12 'recipe_engine/context',
13 'recipe_engine/file',
14 'recipe_engine/path',
15 'recipe_engine/properties',
16 'recipe_engine/python',
17 'recipe_engine/step',
18 'run',
19 'vars',
20]
21
22
Kevin Lubicka0ba6122018-08-15 13:45:28 -040023DOCKER_IMAGE = 'gcr.io/skia-public/gold-karma-chrome-tests:68.0.3440.106_v1'
24INNER_KARMA_SCRIPT = '/SRC/skia/infra/pathkit/docker/test_pathkit.sh'
Kevin Lubick92c91712018-08-09 10:00:02 -040025
26
27
28def RunSteps(api):
29 api.vars.setup()
30 checkout_root = api.checkout.default_checkout_root
31 out_dir = api.vars.swarming_out_dir
32 api.checkout.bot_update(checkout_root=checkout_root)
33
34 # Make sure this exists, otherwise Docker will make it with root permissions.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040035 api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777)
Kevin Lubick92c91712018-08-09 10:00:02 -040036
37 copy_dest = api.path.join(checkout_root, 'skia', 'experimental', 'pathkit',
38 'npm-wasm', 'bin', 'test')
39
40 helper_js = api.vars.build_dir.join('pathkit.js')
41 wasm = api.vars.build_dir.join('pathkit.wasm')
42
43 api.python.inline(
Kevin Lubicka0ba6122018-08-15 13:45:28 -040044 name='Set up for docker',
Kevin Lubick92c91712018-08-09 10:00:02 -040045 program='''import errno
46import os
47import shutil
48import sys
49
50copy_dest = sys.argv[1]
51helper_js = sys.argv[2]
52wasm = sys.argv[3]
Kevin Lubicka0ba6122018-08-15 13:45:28 -040053out_dir = sys.argv[4]
Kevin Lubick92c91712018-08-09 10:00:02 -040054
55# Clean out old binaries (if any)
56try:
57 shutil.rmtree(copy_dest)
58except OSError as e:
59 if e.errno != errno.ENOENT:
60 raise
61
62# Make folder
63try:
64 os.makedirs(copy_dest)
65except OSError as e:
66 if e.errno != errno.EEXIST:
67 raise
68
Kevin Lubicka0ba6122018-08-15 13:45:28 -040069# Copy binaries (pathkit.js and pathkit.wasm) to where the karma tests
70# expect them ($SKIA_ROOT/experimental/pathkit/npm-wasm/test/)
Kevin Lubick92c91712018-08-09 10:00:02 -040071dest = os.path.join(copy_dest, 'pathkit.js')
72shutil.copyfile(helper_js, dest)
73os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
74
75dest = os.path.join(copy_dest, 'pathkit.wasm')
76shutil.copyfile(wasm, dest)
77os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read.
Kevin Lubicka0ba6122018-08-15 13:45:28 -040078
79# Prepare output folder
80os.chmod(out_dir, 0o777) # important, otherwise non-privileged docker can't write.
Kevin Lubick92c91712018-08-09 10:00:02 -040081''',
Kevin Lubicka0ba6122018-08-15 13:45:28 -040082 args=[copy_dest, helper_js, wasm, out_dir],
Kevin Lubick92c91712018-08-09 10:00:02 -040083 infra_step=True)
84
Kevin Lubicka0ba6122018-08-15 13:45:28 -040085
Kevin Lubick92c91712018-08-09 10:00:02 -040086
87 cmd = ['docker', 'run', '--shm-size=2gb', '--rm',
88 '-v', '%s:/SRC' % checkout_root, '-v', '%s:/OUT' % out_dir,
Kevin Lubicka0ba6122018-08-15 13:45:28 -040089 DOCKER_IMAGE, INNER_KARMA_SCRIPT,
90 '--builder', api.vars.builder_name,
91 '--git_hash', api.properties['revision'],
92 '--buildbucket_build_id', api.properties.get('buildbucket_build_id',
93 ''),
94 '--bot_id', api.vars.swarming_bot_id,
95 '--task_id', api.vars.swarming_task_id,
96 '--browser', 'Chrome',
97 '--config', api.vars.configuration,
98 ]
99
100 if api.vars.is_trybot:
101 cmd.extend([
102 '--issue', api.vars.issue,
103 '--patchset', api.vars.patchset,
104 '--patch_storage', api.vars.patch_storage,
105 ])
Kevin Lubick92c91712018-08-09 10:00:02 -0400106
107 api.run(
108 api.step,
109 'Test PathKit with Docker',
110 cmd=cmd)
111
112
113def GenTests(api):
114 yield (
115 api.test('pathkit_test') +
116 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
117 '-wasm-Debug-All-PathKit'),
118 repository='https://skia.googlesource.com/skia.git',
119 revision='abc123',
120 path_config='kitchen',
121 swarm_out_dir='[SWARM_OUT_DIR]')
122 )
Kevin Lubicka0ba6122018-08-15 13:45:28 -0400123
124 yield (
125 api.test('pathkit_trybot') +
126 api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2'
127 '-wasm-Debug-All-PathKit'),
128 repository='https://skia.googlesource.com/skia.git',
129 revision='abc123',
130 path_config='kitchen',
131 swarm_out_dir='[SWARM_OUT_DIR]',
132 patch_storage='gerrit',
133 patch_set=7,
134 patch_issue=1234,
135 gerrit_project='skia',
136 gerrit_url='https://skia-review.googlesource.com/')
137 )