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 | |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 23 | DOCKER_IMAGE = 'gcr.io/skia-public/gold-karma-chrome-tests:68.0.3440.106_v1' |
| 24 | INNER_KARMA_SCRIPT = '/SRC/skia/infra/pathkit/docker/test_pathkit.sh' |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 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. |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 35 | api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777) |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 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( |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 44 | name='Set up for docker', |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 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] |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 53 | out_dir = sys.argv[4] |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 54 | |
| 55 | # Clean out old binaries (if any) |
| 56 | try: |
| 57 | shutil.rmtree(copy_dest) |
| 58 | except OSError as e: |
| 59 | if e.errno != errno.ENOENT: |
| 60 | raise |
| 61 | |
| 62 | # Make folder |
| 63 | try: |
| 64 | os.makedirs(copy_dest) |
| 65 | except OSError as e: |
| 66 | if e.errno != errno.EEXIST: |
| 67 | raise |
| 68 | |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 69 | # Copy binaries (pathkit.js and pathkit.wasm) to where the karma tests |
| 70 | # expect them ($SKIA_ROOT/experimental/pathkit/npm-wasm/test/) |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 71 | dest = os.path.join(copy_dest, 'pathkit.js') |
| 72 | shutil.copyfile(helper_js, dest) |
| 73 | os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read. |
| 74 | |
| 75 | dest = os.path.join(copy_dest, 'pathkit.wasm') |
| 76 | shutil.copyfile(wasm, dest) |
| 77 | os.chmod(dest, 0o644) # important, otherwise non-privileged docker can't read. |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 78 | |
| 79 | # Prepare output folder |
| 80 | 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] | 81 | ''', |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 82 | args=[copy_dest, helper_js, wasm, out_dir], |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 83 | infra_step=True) |
| 84 | |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 85 | |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 86 | |
| 87 | cmd = ['docker', 'run', '--shm-size=2gb', '--rm', |
| 88 | '-v', '%s:/SRC' % checkout_root, '-v', '%s:/OUT' % out_dir, |
Kevin Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 89 | 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 Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 106 | |
| 107 | api.run( |
| 108 | api.step, |
| 109 | 'Test PathKit with Docker', |
| 110 | cmd=cmd) |
| 111 | |
| 112 | |
| 113 | def 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 Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame^] | 123 | |
| 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 | ) |