Skip to content

Commit

Permalink
Excavator: Update godel to latest version (palantir#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot authored May 4, 2021
1 parent ef0dc94 commit f37ac17
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
4 changes: 2 additions & 2 deletions godel/config/godel.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
distributionURL=https://github.com/palantir/godel/releases/download/v2.36.0/godel-2.36.0.tgz
distributionSHA256=91137f4fb9e1b4491d6dd821edf6ed39eb66f21410bf645a062f687049c45492
distributionURL=https://github.com/palantir/godel/releases/download/v2.39.0/godel-2.39.0.tgz
distributionSHA256=6db200926037532f2f22322c84be8c34808e5acf89cad6200c9d7a9857fc0fa2
41 changes: 28 additions & 13 deletions godelw
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
set -euo pipefail

# Version and checksums for godel. Values are populated by the godel "dist" task.
VERSION=2.36.0
DARWIN_CHECKSUM=ac46bc231177ddd78343ef66fab222de7a91d9e691f8480f1d644561a08e92d0
LINUX_CHECKSUM=604db3bba458be15360c0a9669119b6797cebf013d839de88d0a7eca59adf03e
VERSION=2.39.0
DARWIN_AMD64_CHECKSUM=2e8bb7d29d044352ba61d1216e4d06fff2390b79c533928923870711f8ae6f42
DARWIN_ARM64_CHECKSUM=ee342e29a8520d4d676184cbaecd6a9d2989422b0b268d7e033071cff86f78ab
LINUX_AMD64_CHECKSUM=9bbc5cff2516d75244503f264e1c8b18349e29886ed33f6e8177afc587a1baf0
LINUX_ARM64_CHECKSUM=9c5191d26c2cb690c76576caa23e72e303e6c5bcc006684b7d17d3246d8fc1f2

# Downloads file at URL to destination path using wget or curl. Prints an error and exits if wget or curl is not present.
function download {
Expand Down Expand Up @@ -108,7 +110,7 @@ function verify_dist_tgz_valid {
local tgz_path=$1
local version=$2

local expected_paths=("godel-$version/" "godel-$version/bin/darwin-amd64/godel" "godel-$version/bin/linux-amd64/godel" "godel-$version/wrapper/godelw" "godel-$version/wrapper/godel/config/")
local expected_paths=("godel-$version/" "godel-$version/bin/darwin-amd64/godel" "godel-$version/bin/darwin-arm64/godel" "godel-$version/bin/linux-amd64/godel" "godel-$version/bin/linux-arm64/godel" "godel-$version/wrapper/godelw" "godel-$version/wrapper/godel/config/")
local files=($(tar -tf "$tgz_path"))

# this is a double-for loop, but fine since $expected_paths is small and bash doesn't have good primitives for set/map/list manipulation
Expand Down Expand Up @@ -142,9 +144,10 @@ function verify_godel_version {
local base_dir=$1
local version=$2
local os=$3
local arch=$4

local expected_output="godel version $version"
local version_output=$($base_dir/godel-$version/bin/$os-amd64/godel version)
local version_output=$($base_dir/godel-$version/bin/$os-$arch/godel version)

if [ "$expected_output" != "$version_output" ]; then
echo "Version reported by godel executable did not match expected version: expected \"$expected_output\", was \"$version_output\""
Expand All @@ -161,23 +164,35 @@ GODEL_BASE_DIR=${GODEL_HOME:-$HOME/.godel}
# determine OS
OS=""
EXPECTED_CHECKSUM=""
case "$(uname)" in
Darwin*)
case "$(uname)-$(uname -m)" in
Darwin-x86_64)
OS=darwin
EXPECTED_CHECKSUM=$DARWIN_CHECKSUM
ARCH=amd64
EXPECTED_CHECKSUM=$DARWIN_AMD64_CHECKSUM
;;
Linux*)
Darwin-arm64)
OS=darwin
ARCH=arm64
EXPECTED_CHECKSUM=$DARWIN_ARM64_CHECKSUM
;;
Linux-x86_64)
OS=linux
ARCH=amd64
EXPECTED_CHECKSUM=$LINUX_AMD64_CHECKSUM
;;
Linux-aarch64)
OS=linux
EXPECTED_CHECKSUM=$LINUX_CHECKSUM
ARCH=arm64
EXPECTED_CHECKSUM=$LINUX_ARM64_CHECKSUM
;;
*)
echo "Unsupported operating system: $(uname)"
echo "Unsupported operating system-architecture: $(uname)-$(uname -m)"
exit 1
;;
esac

# path to godel binary
CMD=$GODEL_BASE_DIR/dists/godel-$VERSION/bin/$OS-amd64/godel
CMD=$GODEL_BASE_DIR/dists/godel-$VERSION/bin/$OS-$ARCH/godel

# godel binary is not present -- download distribution
if [ ! -f "$CMD" ]; then
Expand Down Expand Up @@ -212,7 +227,7 @@ if [ ! -f "$CMD" ]; then
TMP_DIST_DIR=$(mktemp -d "$GODEL_BASE_DIR/tmp_XXXXXX" 2>/dev/null || mktemp -d -t "$GODEL_BASE_DIR/tmp_XXXXXX")
trap 'rm -rf "$TMP_DIST_DIR"' EXIT
tar zxvf "$DOWNLOAD_DST" -C "$TMP_DIST_DIR" >/dev/null 2>&1
verify_godel_version "$TMP_DIST_DIR" "$VERSION" "$OS"
verify_godel_version "$TMP_DIST_DIR" "$VERSION" "$OS" "$ARCH"

# rename downloaded file to remove PID portion
mv "$DOWNLOAD_DST" "$GODEL_BASE_DIR/downloads/godel-$VERSION.tgz"
Expand Down

0 comments on commit f37ac17

Please sign in to comment.