blob: b65e54273472d2756b1fb3676b8f9777a2ccf37a [file] [log] [blame]
Kevin Lubick82999c02018-08-28 10:52:18 -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# Recipe which generates the Gold images for lottie-web using docker
6
7DEPS = [
8 'checkout',
9 'infra',
10 'recipe_engine/file',
11 'recipe_engine/path',
12 'recipe_engine/properties',
13 'recipe_engine/python',
14 'recipe_engine/step',
15 'run',
16 'vars',
17]
18
19
Kevin Lubickd0f0cb82018-09-04 17:00:17 -040020DOCKER_IMAGE = 'gcr.io/skia-public/gold-lottie-web-puppeteer:v2'
Kevin Lubick82999c02018-08-28 10:52:18 -040021LOTTIECAP_SCRIPT = '/SRC/skia/infra/lottiecap/docker/lottiecap_gold.sh'
22
23
24def RunSteps(api):
25 api.vars.setup()
26 checkout_root = api.checkout.default_checkout_root
27 out_dir = api.vars.swarming_out_dir
28 lottie_files_src = api.vars.slave_dir.join('lottie-samples')
29 lottie_files_dir = '/tmp/lottie_files'
Kevin Lubickd0f0cb82018-09-04 17:00:17 -040030 # The lottie-web repo is DEP'd in. This links to its build directory
31 # to make finding the lottie.min.js easier to reference from inside
32 # the docker image.
33 lottie_build = checkout_root.join('lottie', 'build', 'player')
34
Kevin Lubick82999c02018-08-28 10:52:18 -040035 api.checkout.bot_update(checkout_root=checkout_root)
36
37 # Make sure this exists, otherwise Docker will make it with root permissions.
38 api.file.ensure_directory('mkdirs out_dir', out_dir, mode=0777)
39 # When lottie files are brought in via isolate or CIPD, they are just
40 # symlinks, which does not work well with Docker because we can't mount
41 # the folder as a volume.
42 # e.g. /LOTTIE_FILES/foo.json -> ../.cipd/alpha/beta/foo.json
43 # To get around this, we just copy the lottie files into a temporary
44 # directory.
45 api.file.rmtree('remove previous lottie files', lottie_files_dir)
46 api.file.copytree('copy lottie files', lottie_files_src, lottie_files_dir)
47
48 api.python.inline(
49 name='Set up for docker',
50 program='''
51import os
52import sys
53
54lottie_files_dir = sys.argv[1]
55out_dir = sys.argv[2]
Kevin Lubickd0f0cb82018-09-04 17:00:17 -040056lottie_build = sys.argv[3]
Kevin Lubick82999c02018-08-28 10:52:18 -040057
58# Make sure all the lottie files are readable by everyone so we can see
59# them in the docker container.
60os.system('chmod 0644 %s/*' % lottie_files_dir)
Kevin Lubickd0f0cb82018-09-04 17:00:17 -040061os.system('chmod 0644 %s/*' % lottie_build)
Kevin Lubick82999c02018-08-28 10:52:18 -040062
63# Prepare output folder, api.file.ensure_directory doesn't touch
64# the permissions of the out directory if it already exists.
65# This typically means that the non-privileged docker won't be able to write.
66os.chmod(out_dir, 0o777)
67''',
Kevin Lubickd0f0cb82018-09-04 17:00:17 -040068 args=[lottie_files_dir, out_dir, lottie_build],
Kevin Lubick82999c02018-08-28 10:52:18 -040069 infra_step=True)
70
71 cmd = ['docker', 'run', '--shm-size=2gb', '--rm',
72 '-v', '%s:/SRC' % checkout_root,
73 '-v', '%s:/OUT' % out_dir,
Kevin Lubickd0f0cb82018-09-04 17:00:17 -040074 '-v', '%s:/LOTTIE_BUILD' % lottie_build,
Kevin Lubick82999c02018-08-28 10:52:18 -040075 '-v', '%s:/LOTTIE_FILES' % lottie_files_dir]
76
77 cmd.extend([
78 DOCKER_IMAGE, LOTTIECAP_SCRIPT,
79 '--builder', api.vars.builder_name,
80 '--git_hash', api.properties['revision'],
81 '--buildbucket_build_id', api.properties.get('buildbucket_build_id',
82 ''),
83 '--bot_id', api.vars.swarming_bot_id,
84 '--task_id', api.vars.swarming_task_id,
85 '--browser', 'Chrome',
86 '--config', api.vars.configuration,
87 ])
88
89 if api.vars.is_trybot:
90 cmd.extend([
91 '--issue', api.vars.issue,
92 '--patchset', api.vars.patchset,
93 '--patch_storage', api.vars.patch_storage,
94 ])
95
96 api.run(
97 api.step,
98 'Create lottie-web Gold output with Docker',
99 cmd=cmd)
100
101
102def GenTests(api):
103 yield (
104 api.test('Test-Debian9-none-GCE-CPU-AVX2-x86_64-Debug-All-LottieWeb') +
105 api.properties(buildername=('Test-Debian9-none-GCE-CPU-AVX2'
106 '-x86_64-Debug-All-LottieWeb'),
107 repository='https://skia.googlesource.com/skia.git',
108 revision='abc123',
109 path_config='kitchen',
110 swarm_out_dir='[SWARM_OUT_DIR]')
111 )
112
113 yield (
114 api.test('lottie_web_trybot') +
115 api.properties(buildername=('Test-Debian9-none-GCE-CPU-AVX2'
116 '-x86_64-Debug-All-LottieWeb'),
117 repository='https://skia.googlesource.com/skia.git',
118 revision='abc123',
119 path_config='kitchen',
120 swarm_out_dir='[SWARM_OUT_DIR]',
121 patch_storage='gerrit',
122 patch_set=7,
123 patch_issue=1234,
124 gerrit_project='skia',
125 gerrit_url='https://skia-review.googlesource.com/')
126 )