skia2/infra/lottiecap/docker/lottiecap_gold.sh
Kevin Lubick 82999c037e Add docker-based infrastructure for Gold/lottie-web integration
This adds 2 docker containers (based on the ones used for PathKit
added in https://skia-review.googlesource.com/c/skia/+/147042)
which bundle Chrome and puppeteer to allow the lottiecap.js
to be run anywhere.

This adds a recipe (test_lottie_web.py) to drive the docker
container and do a little bit of set-up (and a few docs/bug
fixes discovered in the test_pathkit.py that it was based on).

Additionally, this modifies lottiecap.js to support POSTing
output to a running go server (again, the same as PathKit)
which has the image data hashed and the metadata added to
a large JSON output.

This re-works driver.html to avoid re-loading the JSON object
25 times. The performance boost is important because, right now,
the lottie files are processed individually.

In a future CL, I want to address the two TODOs in
lottie-web-aggregator.go

Bug: skia:8108
Change-Id: I100c9ce23dcc5033a27287211cbf0db898960da9
Reviewed-on: https://skia-review.googlesource.com/149282
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Stephan Altmueller <stephana@google.com>
2018-08-28 15:16:22 +00:00

43 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2018 Google LLC
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This assumes it is being run inside a docker container of gold-karma-chrome-tests
# and a Skia checkout has been mounted at /SRC, the output directory
# is mounted at /OUT, and any lottie json files are in a folder and mounted
# at /LOTTIE_FILES.
# For example:
# docker run -v ~/lottie-samples:/LOTTIE_FILES -v $SKIA_ROOT:/SRC -v /tmp/dockerout:/OUT gcr.io/skia-public/gold-lottie-web-puppeteer:5.2.1_v1 /SRC/infra/lottiecap/docker/lottiecap_gold.sh
set -ex
#BASE_DIR is the dir this script is in ($SKIA_ROOT/infra/lottiecap/docker)
BASE_DIR=`cd $(dirname ${BASH_SOURCE[0]}) && pwd`
LOTTIECAP_DIR=$BASE_DIR/../../../tools/lottiecap
# Start the aggregator in the background
/opt/gold-aggregator $@ &
cd $LOTTIECAP_DIR
# lottie files may have spaces in their names, so a naive bash for loop
# did not work here.
find /LOTTIE_FILES -not -path /LOTTIE_FILES -exec \
node ./lottiecap.js --port 8082 \
--lottie_player /usr/local/lib/node_modules/lottie-web/build/player/lottie.min.js \
--in_docker \
--post_to http://localhost:8081/report_gold_data \
--input {} \;
# Tell the aggregator to dump the json
# This curl command gets the HTTP code and stores it into $CODE
CODE=`curl -s -o /dev/null -I -w "%{http_code}" -X POST localhost:8081/dump_json`
if [ $CODE -ne 200 ]; then
# If we don't get 200 back, something is wrong with writing to disk, so exit with error
exit 1
fi