Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 1 | # 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 Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 5 | # Recipe which runs the PathKit tests using docker |
| 6 | |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 7 | DEPS = [ |
| 8 | 'checkout', |
Ben Wagner | 325778b | 2019-01-22 18:09:30 -0500 | [diff] [blame] | 9 | 'env', |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 10 | 'infra', |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 11 | '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 Lubick | d618027 | 2019-03-12 14:06:19 -0400 | [diff] [blame] | 21 | DOCKER_IMAGE = 'gcr.io/skia-public/gold-karma-chrome-tests:72.0.3626.121_v1' |
Kevin Lubick | 8e9750d | 2018-10-09 09:36:35 -0400 | [diff] [blame] | 22 | INNER_KARMA_SCRIPT = '/SRC/skia/infra/pathkit/test_pathkit.sh' |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 23 | |
| 24 | |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 25 | def 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 Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 32 | api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777) |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 33 | |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 34 | # 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 Lubick | c7d0571 | 2018-08-31 10:03:23 -0400 | [diff] [blame] | 36 | copy_dest = checkout_root.join('skia', 'modules', 'pathkit', |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 37 | 'npm-wasm', 'bin', 'test') |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 38 | if 'asmjs' in api.vars.builder_name: |
Kevin Lubick | c7d0571 | 2018-08-31 10:03:23 -0400 | [diff] [blame] | 39 | copy_dest = checkout_root.join('skia', 'modules', 'pathkit', |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 40 | 'npm-asmjs', 'bin', 'test') |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 41 | |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 42 | 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 Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 51 | |
| 52 | api.python.inline( |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 53 | name='Set up for docker', |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 54 | program='''import errno |
| 55 | import os |
| 56 | import shutil |
| 57 | import sys |
| 58 | |
| 59 | copy_dest = sys.argv[1] |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 60 | base_dir = sys.argv[2] |
| 61 | bundle_name = sys.argv[3] |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 62 | out_dir = sys.argv[4] |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 63 | |
| 64 | # Clean out old binaries (if any) |
| 65 | try: |
| 66 | shutil.rmtree(copy_dest) |
| 67 | except OSError as e: |
| 68 | if e.errno != errno.ENOENT: |
| 69 | raise |
| 70 | |
| 71 | # Make folder |
| 72 | try: |
| 73 | os.makedirs(copy_dest) |
| 74 | except OSError as e: |
| 75 | if e.errno != errno.EEXIST: |
| 76 | raise |
| 77 | |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 78 | # Copy binaries (pathkit.js and pathkit.wasm) to where the karma tests |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 79 | # expect them ($SKIA_ROOT/modules/pathkit/npm-wasm/bin/test/) |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 80 | dest = os.path.join(copy_dest, 'pathkit.js') |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 81 | shutil.copyfile(os.path.join(base_dir, 'pathkit.js'), dest) |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 82 | os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read. |
| 83 | |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 84 | if 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 Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 88 | |
Kevin Lubick | 82999c0 | 2018-08-28 10:52:18 -0400 | [diff] [blame] | 89 | # Prepare output folder, api.file.ensure_directory doesn't touch |
| 90 | # the permissions of the out directory if it already exists. |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 91 | os.chmod(out_dir, 0o777) # important, otherwise non-privileged docker can't write. |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 92 | ''', |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 93 | args=[copy_dest, base_dir, bundle_name, out_dir], |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 94 | infra_step=True) |
| 95 | |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 96 | |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 97 | cmd = ['docker', 'run', '--shm-size=2gb', '--rm', |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 98 | '--volume', '%s:/SRC' % checkout_root, |
| 99 | '--volume', '%s:/OUT' % out_dir] |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 100 | |
| 101 | if 'asmjs' in api.vars.builder_name: |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 102 | cmd.extend(['--env', 'ASM_JS=1']) |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 103 | |
| 104 | cmd.extend([ |
Kevin Lubick | 3d99b1e | 2018-10-16 10:15:01 -0400 | [diff] [blame] | 105 | 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 Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 116 | |
| 117 | if 'asmjs' in api.vars.builder_name: |
| 118 | cmd.extend(['--compiled_language', 'asmjs']) # the default is wasm |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 119 | |
| 120 | if api.vars.is_trybot: |
| 121 | cmd.extend([ |
| 122 | '--issue', api.vars.issue, |
| 123 | '--patchset', api.vars.patchset, |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 124 | ]) |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 125 | |
Ben Wagner | 325778b | 2019-01-22 18:09:30 -0500 | [diff] [blame] | 126 | # 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 Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 133 | |
| 134 | |
| 135 | def GenTests(api): |
| 136 | yield ( |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 137 | api.test('Test-Debian9-EMCC-GCE-CPU-AVX2-wasm-Debug-All-PathKit') + |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 138 | 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 Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 145 | |
| 146 | yield ( |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 147 | 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 Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 167 | 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 Boren | 858f648 | 2018-09-12 14:39:34 -0400 | [diff] [blame] | 174 | patch_ref='89/456789/12', |
| 175 | patch_repo='https://skia.googlesource.com/skia.git', |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 176 | patch_storage='gerrit', |
| 177 | patch_set=7, |
| 178 | patch_issue=1234, |
| 179 | gerrit_project='skia', |
| 180 | gerrit_url='https://skia-review.googlesource.com/') |
| 181 | ) |