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# Recipe which generates the Gold images for lottie-web using docker 6 7PYTHON_VERSION_COMPATIBILITY = "PY2+3" 8 9DEPS = [ 10 'checkout', 11 'docker', 12 'env', 13 'flavor', 14 'gold_upload', 15 'infra', 16 'recipe_engine/file', 17 'recipe_engine/path', 18 'recipe_engine/properties', 19 'recipe_engine/step', 20 'run', 21 'vars', 22] 23 24 25DOCKER_IMAGE = 'gcr.io/skia-public/gold-lottie-web-puppeteer:v2' 26LOTTIECAP_SCRIPT = 'skia/infra/lottiecap/docker/lottiecap_gold.sh' 27 28 29def RunSteps(api): 30 api.vars.setup() 31 api.flavor.setup("dm") 32 checkout_root = api.path['start_dir'] 33 out_dir = api.vars.swarming_out_dir 34 lottie_files_src = api.vars.workdir.join('lottie-samples') 35 lottie_files_dir = '/tmp/lottie_files' 36 # The lottie-web repo is DEP'd in. This links to its build directory 37 # to make finding the lottie.min.js easier to reference from inside 38 # the docker image. 39 lottie_build = checkout_root.join('lottie', 'build', 'player') 40 41 # Make sure this exists, otherwise Docker will make it with root permissions. 42 api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0o777) 43 # When lottie files are brought in via isolate or CIPD, they are just 44 # symlinks, which does not work well with Docker because we can't mount 45 # the folder as a volume. 46 # e.g. /LOTTIE_FILES/foo.json -> ../.cipd/alpha/beta/foo.json 47 # To get around this, we just copy the lottie files into a temporary 48 # directory. 49 api.file.rmtree('remove previous lottie files', lottie_files_dir) 50 api.file.copytree('copy lottie files', lottie_files_src, lottie_files_dir) 51 52 recursive_read = [lottie_build, lottie_files_dir] 53 54 docker_args = [ 55 '--mount', 56 'type=bind,source=%s,target=/LOTTIE_BUILD' % lottie_build, 57 '--mount', 58 'type=bind,source=%s,target=/LOTTIE_FILES' % lottie_files_dir 59 ] 60 61 args = [ 62 '--builder', api.vars.builder_name, 63 '--git_hash', api.properties['revision'], 64 '--buildbucket_build_id', api.properties.get('buildbucket_build_id', 65 ''), 66 '--bot_id', api.vars.swarming_bot_id, 67 '--task_id', api.vars.swarming_task_id, 68 '--browser', 'Chrome', 69 '--config', api.vars.configuration, 70 ] 71 72 if api.vars.is_trybot: 73 args.extend([ 74 '--issue', api.vars.issue, 75 '--patchset', api.vars.patchset, 76 '--patch_storage', api.vars.patch_storage, 77 ]) 78 79 api.docker.run( 80 name='Generate LottieWeb Gold output with Docker', 81 docker_image=DOCKER_IMAGE, 82 src_dir=checkout_root, 83 out_dir=out_dir, 84 script=checkout_root.join(LOTTIECAP_SCRIPT), 85 args=args, 86 docker_args=docker_args, 87 recursive_read=recursive_read, 88 attempts=3, 89 ) 90 91 api.gold_upload.upload() 92 93 94def GenTests(api): 95 yield ( 96 api.test('Test-Debian10-none-GCE-CPU-AVX2-x86_64-Debug-All-LottieWeb') + 97 api.properties(buildername=('Test-Debian10-none-GCE-CPU-AVX2' 98 '-x86_64-Debug-All-LottieWeb'), 99 repository='https://skia.googlesource.com/skia.git', 100 revision='abc123', 101 gs_bucket='skia-infra-gm', 102 path_config='kitchen', 103 swarm_out_dir='[SWARM_OUT_DIR]') 104 ) 105 106 yield ( 107 api.test('lottie_web_trybot') + 108 api.properties(buildername=('Test-Debian10-none-GCE-CPU-AVX2' 109 '-x86_64-Debug-All-LottieWeb'), 110 repository='https://skia.googlesource.com/skia.git', 111 revision='abc123', 112 gs_bucket='skia-infra-gm', 113 path_config='kitchen', 114 swarm_out_dir='[SWARM_OUT_DIR]', 115 patch_ref='89/456789/12', 116 patch_repo='https://skia.googlesource.com/skia.git', 117 patch_storage='gerrit', 118 patch_set=7, 119 patch_issue=1234, 120 gerrit_project='skia', 121 gerrit_url='https://skia-review.googlesource.com/') 122 ) 123