1cb93a386Sopenharmony_ci#!/bin/bash 2cb93a386Sopenharmony_ci# Copyright 2018 Google LLC 3cb93a386Sopenharmony_ci# 4cb93a386Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci# found in the LICENSE file. 6cb93a386Sopenharmony_ci 7cb93a386Sopenharmony_ci# This assumes it is being run inside a docker container of gold-karma-chrome-tests 8cb93a386Sopenharmony_ci# and a Skia checkout has been mounted at /SRC, the output directory 9cb93a386Sopenharmony_ci# is mounted at /OUT, and any lottie json files are in a folder and mounted 10cb93a386Sopenharmony_ci# at /LOTTIE_FILES. 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_ci# For example: 13cb93a386Sopenharmony_ci# docker run -v ~/lottie-samples:/LOTTIE_FILES -v $LOTTIE_ROOT/build/player:/LOTTIE_BUILD -v $SKIA_ROOT:/SRC -v /tmp/dockerout:/OUT gcr.io/skia-public/gold-lottie-web-puppeteer:v2 /SRC/infra/lottiecap/docker/lottiecap_gold.sh 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_ciset -ex 16cb93a386Sopenharmony_ci 17cb93a386Sopenharmony_ci#BASE_DIR is the dir this script is in ($SKIA_ROOT/infra/lottiecap/docker) 18cb93a386Sopenharmony_ciBASE_DIR=`cd $(dirname ${BASH_SOURCE[0]}) && pwd` 19cb93a386Sopenharmony_ciLOTTIECAP_DIR=$BASE_DIR/../../../tools/lottiecap 20cb93a386Sopenharmony_ci 21cb93a386Sopenharmony_ci# Start the aggregator in the background 22cb93a386Sopenharmony_ci/opt/gold-aggregator $@ & 23cb93a386Sopenharmony_ci 24cb93a386Sopenharmony_cicd $LOTTIECAP_DIR 25cb93a386Sopenharmony_ci 26cb93a386Sopenharmony_ci# lottie files may have spaces in their names, so a naive bash for loop 27cb93a386Sopenharmony_ci# did not work here. 28cb93a386Sopenharmony_cifind /LOTTIE_FILES -not -path /LOTTIE_FILES -exec \ 29cb93a386Sopenharmony_ci node ./lottiecap.js --port 8082 \ 30cb93a386Sopenharmony_ci --lottie_player /LOTTIE_BUILD/lottie.min.js \ 31cb93a386Sopenharmony_ci --in_docker \ 32cb93a386Sopenharmony_ci --post_to http://localhost:8081/report_gold_data \ 33cb93a386Sopenharmony_ci --input {} \; 34cb93a386Sopenharmony_ci 35cb93a386Sopenharmony_ci 36cb93a386Sopenharmony_ci# Tell the aggregator to dump the json 37cb93a386Sopenharmony_ci# This curl command gets the HTTP code and stores it into $CODE 38cb93a386Sopenharmony_ciCODE=`curl -s -o /dev/null -I -w "%{http_code}" -X POST localhost:8081/dump_json` 39cb93a386Sopenharmony_ciif [ $CODE -ne 200 ]; then 40cb93a386Sopenharmony_ci # If we don't get 200 back, something is wrong with writing to disk, so exit with error 41cb93a386Sopenharmony_ci exit 1 42cb93a386Sopenharmony_cifi 43