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 | |
| 5 | |
| 6 | # Recipe which runs the PathKit tests using docker |
| 7 | |
| 8 | |
| 9 | DEPS = [ |
| 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 | |
| 23 | DOCKER_IMAGE = 'gcr.io/skia-public/karma-chrome-tests:68.0.3440.106_v1' |
| 24 | INNER_KARMA_CONFIG = '/SRC/skia/experimental/pathkit/karma-docker.conf.js' |
| 25 | |
| 26 | |
| 27 | |
| 28 | def 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. |
| 35 | api.file.ensure_directory('mkdirs out_dir', out_dir) |
| 36 | |
| 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( |
| 44 | name='copy built wasm to location docker can see', |
| 45 | program='''import errno |
| 46 | import os |
| 47 | import shutil |
| 48 | import sys |
| 49 | |
| 50 | copy_dest = sys.argv[1] |
| 51 | helper_js = sys.argv[2] |
| 52 | wasm = sys.argv[3] |
| 53 | |
| 54 | # Clean out old binaries (if any) |
| 55 | try: |
| 56 | shutil.rmtree(copy_dest) |
| 57 | except OSError as e: |
| 58 | if e.errno != errno.ENOENT: |
| 59 | raise |
| 60 | |
| 61 | # Make folder |
| 62 | try: |
| 63 | os.makedirs(copy_dest) |
| 64 | except OSError as e: |
| 65 | if e.errno != errno.EEXIST: |
| 66 | raise |
| 67 | |
| 68 | dest = os.path.join(copy_dest, 'pathkit.js') |
| 69 | shutil.copyfile(helper_js, dest) |
| 70 | os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read. |
| 71 | |
| 72 | dest = os.path.join(copy_dest, 'pathkit.wasm') |
| 73 | shutil.copyfile(wasm, dest) |
| 74 | os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read. |
| 75 | ''', |
| 76 | args=[copy_dest, helper_js, wasm], |
| 77 | infra_step=True) |
| 78 | |
| 79 | # Remove any previous npm-wasm/bin/test and mkdir |
| 80 | # Copy built binaries to npm-wasm/bin/test |
| 81 | |
| 82 | cmd = ['docker', 'run', '--shm-size=2gb', '--rm', |
| 83 | '-v', '%s:/SRC' % checkout_root, '-v', '%s:/OUT' % out_dir, |
| 84 | DOCKER_IMAGE, 'karma', 'start', INNER_KARMA_CONFIG, '--single-run'] |
| 85 | |
| 86 | api.run( |
| 87 | api.step, |
| 88 | 'Test PathKit with Docker', |
| 89 | cmd=cmd) |
| 90 | |
| 91 | |
| 92 | def GenTests(api): |
| 93 | yield ( |
| 94 | api.test('pathkit_test') + |
| 95 | api.properties(buildername=('Test-Debian9-EMCC-GCE-CPU-AVX2' |
| 96 | '-wasm-Debug-All-PathKit'), |
| 97 | repository='https://skia.googlesource.com/skia.git', |
| 98 | revision='abc123', |
| 99 | path_config='kitchen', |
| 100 | swarm_out_dir='[SWARM_OUT_DIR]') |
| 101 | ) |