#!/usr/bin/env bash

if [ $# -ne 5 ]; then
  echo "Usage: $0 <kitt|prius> <baseline run id> <baseline name> <candidate run id> <candidate name>"
  exit 1
fi

source $ZOOX_WORKSPACE_ROOT/scripts/shell/zooxrc.sh

today="$(date +%Y-%m-%d)"
family="$1"
baseline_runid="$2"
baseline_name="$3"
candidate_runid="$4"
candidate_name="$5"
filename="daily_integration_${today}_${family}.html"
tmppath="/tmp/${filename}"
s3path="s3://zoox-web/perf/cpu-utilization-reports/${filename}"
s3url="http://perf.web.zooxlabs.com/cpu-utilization-reports/${filename}"

brun //scripts/perf/cpu_utilization_report:cpu_utilization_report -- \
  --output "$tmppath" \
  --runs "$baseline_runid" "$candidate_runid" \
  --names "$baseline_name" "$candidate_name"
aws s3 cp "$tmppath" "$s3path"
rm "$tmppath"
echo "Done! Report available at: $s3url"
