Skip to content

Commit

Permalink
chore: Installing proto compiler from gh releases
Browse files Browse the repository at this point in the history
  • Loading branch information
adilansari committed Aug 10, 2022
1 parent 7735178 commit 05d30b2
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-lint.yaml
Expand Up @@ -6,7 +6,7 @@ permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-test.yaml
Expand Up @@ -4,7 +4,7 @@ on:
workflow_call:
jobs:
test:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-debug-image.yaml
Expand Up @@ -18,7 +18,7 @@ env:
jobs:
build-and-push-debug-image:
if: ${{ github.event.label.name == 'debug image' }}
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-docker-image.yaml
Expand Up @@ -20,7 +20,7 @@ env:

jobs:
build-and-push-image:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-docker-local-image.yaml
Expand Up @@ -20,7 +20,7 @@ env:

jobs:
build-and-push-local-image:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: ./.github/workflows/go-lint.yaml

release:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion api/proto
Submodule proto updated from ed4631 to 21374e
2 changes: 2 additions & 0 deletions docker/Dockerfile
Expand Up @@ -22,6 +22,8 @@ RUN apt-get update && \
curl \
gcc \
git \
unzip \
libc6-dev \
make \
sudo

Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.local
Expand Up @@ -21,6 +21,8 @@ RUN apt-get update && \
curl \
wget \
gcc \
libc6-dev \
unzip \
git \
make \
sudo
Expand Down
128 changes: 77 additions & 51 deletions scripts/install_build_deps.sh
Expand Up @@ -16,6 +16,8 @@ set -ex

# Settings
FDB_VERSION=7.1.7
PROTO_VERSION=3.15.8
PROTO_RELEASES="https://github.com/protocolbuffers/protobuf/releases"

### Prereqs checks ###
# Check if architecture and OS is supported
Expand All @@ -24,74 +26,98 @@ ARCH=$(uname -m)
OS=$(uname -s)

case "${OS}-${ARCH}" in
"Darwin-arm64")
BINARIES="brew curl go"
FDB_SHA=b456a1d03580f81394502e1b066006ec38bf6a3a17a9904e6d7a88badbea4b4a08b9dbf69fbb0057b46dd5043f23de9ec3ff7a77d767c23f872425eb73fdee18
;;
"Darwin-x86_64")
BINARIES="brew curl go"
FDB_SHA=0e9d147410eede58d121fdc9208ea7b04a7c74c8f3776f56cfc00233cfb3a358a0e2f992122718ef9c639928b081801da542e9c4b07a539c8fd73361ab43beec
;;
"Linux-aarch64")
BINARIES="apt-get curl go"
FDB_SHA=c994ebb01a660cff9ef699a0e38482a561679db04c02c256efae25ba687cf903
;;
"Linux-arm64")
BINARIES="apt-get curl go"
FDB_SHA=c994ebb01a660cff9ef699a0e38482a561679db04c02c256efae25ba687cf903
;;
"Linux-x86_64")
BINARIES="apt-get curl go"
FDB_SHA=471f6bf4a7af40abc69027aa0d4f452ee83715a43a555008303ca255f6bd6db1
;;
*)
echo "Unsupported architecture ${ARCH} or operating system ${OS}."
exit 1
"Darwin-arm64")
BINARIES="brew curl go"
FDB_SHA=b456a1d03580f81394502e1b066006ec38bf6a3a17a9904e6d7a88badbea4b4a08b9dbf69fbb0057b46dd5043f23de9ec3ff7a77d767c23f872425eb73fdee18
;;
"Darwin-x86_64")
BINARIES="brew curl go"
FDB_SHA=0e9d147410eede58d121fdc9208ea7b04a7c74c8f3776f56cfc00233cfb3a358a0e2f992122718ef9c639928b081801da542e9c4b07a539c8fd73361ab43beec
;;
"Linux-aarch64")
BINARIES="apt-get curl go"
FDB_SHA=c994ebb01a660cff9ef699a0e38482a561679db04c02c256efae25ba687cf903
;;
"Linux-arm64")
BINARIES="apt-get curl go"
FDB_SHA=c994ebb01a660cff9ef699a0e38482a561679db04c02c256efae25ba687cf903
;;
"Linux-x86_64")
BINARIES="apt-get curl go"
FDB_SHA=471f6bf4a7af40abc69027aa0d4f452ee83715a43a555008303ca255f6bd6db1
;;
*)
echo "Unsupported architecture ${ARCH} or operating system ${OS}."
exit 1
;;
esac

# Check if required binaries are available in PATH
for bin in ${BINARIES}; do
binpath=$(command -v "${bin}")
if [ -z "${binpath}" ] || ! test -x "${binpath}"; then
echo "Please ensure that $bin binary is installed and in PATH."
exit 1
fi
binpath=$(command -v "${bin}")
if [ -z "${binpath}" ] || ! test -x "${binpath}"; then
echo "Please ensure that $bin binary is installed and in PATH."
exit 1
fi
done

# Install protobuf compiler via package manager
# Install protobuf compiler
case "${OS}" in
"Darwin")
brew install protobuf
;;
"Linux")
sudo apt-get update
sudo apt-get install -y protobuf-compiler
;;
"Darwin")
brew install protobuf
;;
"Linux")
case "${ARCH}" in
"x86_64")
PROTO_PKG=protoc-$PROTO_VERSION-linux-x86_64.zip
;;
"aarch64")
PROTO_PKG=protoc-$PROTO_VERSION-linux-aarch_64.zip
;;
*)
echo "No supported proto compiler for ${ARCH} or operating system ${OS}."
exit 1
;;
esac
;;
*)
echo "No supported proto compiler for ${ARCH} or operating system ${OS}."
exit 1
;;
esac

if [ -n "$PROTO_PKG" ]; then
DOWNLOAD_URL=$PROTO_RELEASES/download/v$PROTO_VERSION/$PROTO_PKG
echo "Fetching protobuf release ${DOWNLOAD_URL}"
curl -LO $DOWNLOAD_URL
sudo unzip $PROTO_PKG -d "/usr/local/"
sudo chmod +x "/usr/local/bin/protoc"
sudo chmod -R 755 "/usr/local/include/"
fi

# Install protobuf
export GO111MODULE=on
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2
go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0 #generate openapi 3.0 spec
go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1 #generate go http client
go install github.com/mikefarah/yq/v4@latest # used to fix OpenAPI spec in scripts/fix_openapi.sh
go install github.com/mikefarah/yq/v4@latest # used to fix OpenAPI spec in scripts/fix_openapi.sh

# Install FoundationDB package
case "${OS}" in
"Darwin")
FDB_PACKAGE_NAME="FoundationDB-${FDB_VERSION}_${ARCH}.pkg"
FDB_PACKAGE_PATH="$(mktemp -d)/${FDB_PACKAGE_NAME}"
curl --create-dirs -Lo "$FDB_PACKAGE_PATH" "https://tigrisdata-pub.s3.us-west-2.amazonaws.com/${FDB_PACKAGE_NAME}"
echo "$FDB_SHA $FDB_PACKAGE_PATH" | shasum -a 512 -c
sudo installer -pkg "$FDB_PACKAGE_PATH" -target /
;;
"Linux")
FDB_PACKAGE_NAME="foundationdb-clients_${FDB_VERSION}-1_${ARCH}.deb"
FDB_PACKAGE_PATH="$(mktemp -p /tmp/ -u)/${FDB_PACKAGE_NAME}"
curl --create-dirs -Lo "$FDB_PACKAGE_PATH" "https://tigrisdata-pub.s3.us-west-2.amazonaws.com/ubuntu/focal/${FDB_PACKAGE_NAME}"
echo "$FDB_SHA $FDB_PACKAGE_PATH" | sha256sum -c
sudo dpkg -i "$FDB_PACKAGE_PATH" # provides /lib/libfdb_c.so shared library in the docker for CGO
;;
"Darwin")
FDB_PACKAGE_NAME="FoundationDB-${FDB_VERSION}_${ARCH}.pkg"
FDB_PACKAGE_PATH="$(mktemp -d)/${FDB_PACKAGE_NAME}"
curl --create-dirs -Lo "$FDB_PACKAGE_PATH" "https://tigrisdata-pub.s3.us-west-2.amazonaws.com/${FDB_PACKAGE_NAME}"
echo "$FDB_SHA $FDB_PACKAGE_PATH" | shasum -a 512 -c
sudo installer -pkg "$FDB_PACKAGE_PATH" -target /
;;
"Linux")
FDB_PACKAGE_NAME="foundationdb-clients_${FDB_VERSION}-1_${ARCH}.deb"
FDB_PACKAGE_PATH="$(mktemp -p /tmp/ -u)/${FDB_PACKAGE_NAME}"
curl --create-dirs -Lo "$FDB_PACKAGE_PATH" "https://tigrisdata-pub.s3.us-west-2.amazonaws.com/ubuntu/focal/${FDB_PACKAGE_NAME}"
echo "$FDB_SHA $FDB_PACKAGE_PATH" | sha256sum -c
sudo dpkg -i "$FDB_PACKAGE_PATH" # provides /lib/libfdb_c.so shared library in the docker for CGO
;;
esac
2 changes: 2 additions & 0 deletions test/docker/Dockerfile
Expand Up @@ -22,6 +22,8 @@ RUN apt-get update && \
gcc \
git \
golang \
unzip \
libc6-dev \
make \
sudo

Expand Down

0 comments on commit 05d30b2

Please sign in to comment.