Files
radicle-explorer/scripts/install-binaries
T
Thomas Scholtes 40f2b3e516 Tests automatically use heartwood binaries from local test folder
It’s not necessary anymore to add the folder with the heartwood test
binaries to `PATH` before running the end-to-end tests.

Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
2023-06-29 11:34:53 +02:00

73 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
set -e
BINARIES=(rad radicle-node radicle-httpd git-remote-rad)
REPO_ROOT=$(git rev-parse --show-toplevel)
REV=$(cat "$REPO_ROOT/tests/support/heartwood-version")
BINARY_PATH=$REPO_ROOT/tests/tmp/bin/${REV:0:7}
OS=$(uname)
show_usage() {
echo
echo "Installs binaries required for running e2e test suite."
echo
echo "USAGE:"
echo " install-binaries [-s|h]"
echo
echo "OPTIONS:"
echo " -s --show-path Print the binary path, and skip installation."
echo " -h --help Print this Help."
echo
}
while [ $# -ne 0 ]; do
case "$1" in
--show-path | -s)
echo "$BINARY_PATH"
exit
;;
--help | -h)
show_usage
exit
;;
esac
done
echo
echo "Using revision $REV"
echo
mkdir -p "$BINARY_PATH"
for BINARY_NAME in "${BINARIES[@]}"
do
if [ -x "$(command -v "$BINARY_PATH/$BINARY_NAME")" ]; then
echo ✅ "$BINARY_NAME"
else
# To provide deterministic Node and Repo IDs, we need a rad CLI compiled with the --debug flag.
if [ "$BINARY_NAME" = "rad" ]; then
DOWNLOAD_NAME=debug/rad
elif [ "$BINARY_NAME" = "git-remote-rad" ]; then
DOWNLOAD_NAME=debug/git-remote-rad
else
DOWNLOAD_NAME=$BINARY_NAME
fi
case "$OS" in
Darwin)
echo Downloading "$BINARY_NAME" from "https://files.radicle.xyz/$REV/aarch64-apple-darwin/$DOWNLOAD_NAME"
curl --fail -s "https://files.radicle.xyz/$REV/aarch64-apple-darwin/$DOWNLOAD_NAME" --output "$BINARY_PATH/$BINARY_NAME" || (echo "Download failed" && exit 1);;
Linux)
echo Downloading "$BINARY_NAME" from "https://files.radicle.xyz/$REV/x86_64-unknown-linux-musl/$DOWNLOAD_NAME"
curl --fail -s "https://files.radicle.xyz/$REV/x86_64-unknown-linux-musl/$DOWNLOAD_NAME" --output "$BINARY_PATH/$BINARY_NAME" || (echo "Download failed" && exit 1);;
*) echo "There are no precompiled binaries for your OS: $OS, compile $BINARY_NAME manually and make sure it's in PATH." && exit 1 ;;
esac
chmod a+x "$BINARY_PATH/$BINARY_NAME"
fi
done
echo