hannes
6f3c89c91d
This is #88 (reading visualiations from the cache directory), together with shell scripts that can be used as upload hooks to generate the visualizations. Co-authored-by: rand00 <oth.rand@gmail.com> Co-authored-by: Hannes Mehnert <hannes@mehnert.org> Co-authored-by: Reynir Björnsson <reynir@reynir.dk> Co-authored-by: Robur <team@robur.coop> Reviewed-on: https://git.robur.io/robur/builder-web/pulls/90 Co-authored-by: hannes <hannes@mehnert.org> Co-committed-by: hannes <hannes@mehnert.org>
109 lines
2.1 KiB
Bash
Executable file
109 lines
2.1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
set -ex
|
|
|
|
prog_NAME=$(basename "${0}")
|
|
|
|
warn()
|
|
{
|
|
echo "${prog_NAME}: WARN: $*"
|
|
}
|
|
|
|
err()
|
|
{
|
|
echo "${prog_NAME}: ERROR: $*" 1>&2
|
|
}
|
|
|
|
die()
|
|
{
|
|
echo "${prog_NAME}: ERROR: $*" 1>&2
|
|
exit 1
|
|
}
|
|
|
|
usage()
|
|
{
|
|
cat <<EOM 1>&2
|
|
usage: ${prog_NAME} [ OPTIONS ] FILE
|
|
Generates visualizations
|
|
Options:
|
|
--debug-binary=STRING
|
|
Path to debug binary.
|
|
--opam-switch=STRING
|
|
Path to opam switch.
|
|
--uuid=STRING
|
|
UUID of build.
|
|
--cache-dir=STRING
|
|
Path to the cache directory.
|
|
EOM
|
|
exit 1
|
|
}
|
|
|
|
DEBUG=
|
|
OPAM=
|
|
UUID=
|
|
CACHE=
|
|
|
|
while [ $# -gt 1 ]; do
|
|
OPT="$1"
|
|
|
|
case "${OPT}" in
|
|
--debug-binary=*)
|
|
DEBUG="${OPT##*=}"
|
|
;;
|
|
--opam-switch=*)
|
|
OPAM="${OPT##*=}"
|
|
;;
|
|
--uuid=*)
|
|
UUID="${OPT##*=}"
|
|
;;
|
|
--cache-dir=*)
|
|
CACHE="${OPT##*=}"
|
|
;;
|
|
--*)
|
|
warn "Ignoring unknown option: '${OPT}'"
|
|
;;
|
|
*)
|
|
err "Unknown option: '${OPT}'"
|
|
usage
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
[ -z "${UUID}" ] && die "The --uuid option must be specified"
|
|
[ -z "${CACHE}" ] && die "The --cache-dir option must be specified"
|
|
[ -z "${OPAM}" ] && die "The --opam-switch option must be specified"
|
|
|
|
FILENAME="${1}"
|
|
CACHE_DIR="${CACHE}/${UUID}"
|
|
BUILDER_VIZ="builder-viz"
|
|
|
|
TMPTREE=$(mktemp -t treevis)
|
|
TMPOPAM=$(mktemp -t opamvis)
|
|
cleanup () {
|
|
rm -rf "${TMPTREE}" "${TMPOPAM}"
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
if [ -e "${CACHE_DIR}.dependencies.html" ]; then
|
|
echo "Dependency visualization already exists ${CACHE_DIR}.dependencies.html"
|
|
else
|
|
if ${BUILDER_VIZ} dependencies "${OPAM}" > "${TMPOPAM}"; then
|
|
mv "${TMPOPAM}" "${CACHE_DIR}.dependencies.html"
|
|
fi
|
|
fi
|
|
|
|
SIZE="$(stat -f "%z" ${FILENAME})"
|
|
|
|
if [ ! -z "${DEBUG}" ]; then
|
|
if [ -e "${CACHE_DIR}.treemap.html" ]; then
|
|
echo "Treemap visualization already exists ${CACHE_DIR}.treemap.html"
|
|
else
|
|
if ${BUILDER_VIZ} treemap "${DEBUG}" "${SIZE}" > "${TMPTREE}"; then
|
|
mv "${TMPTREE}" "${CACHE_DIR}.treemap.html"
|
|
fi
|
|
fi
|
|
else
|
|
echo "No --debug-binary provided, not producing any treemap"
|
|
fi
|