Skip to content

Commit

Permalink
Add early bailout to bash scripts.
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Littley <[email protected]>
  • Loading branch information
cody-littley committed Oct 7, 2024
1 parent e5f68b2 commit 4f6e25b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/builder/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ docker build \
--tag pbuf-compiler:latest \
--build-arg PROTOC_URL="${PROTOC_URL}" \
.

if [ $? -ne 0 ]; then
exit 1
fi
7 changes: 7 additions & 0 deletions api/builder/protoc-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ if [ -z "$(docker images -q pbuf-compiler:latest 2> /dev/null)" ]; then
"${SCRIPT_DIR}"/build-docker.sh
fi

if [ $? -ne 0 ]; then
exit 1
fi

docker container run \
--rm \
--mount "type=bind,source=${ROOT},target=/home/user/eigenda" \
pbuf-compiler bash -c "source ~/.bashrc && eigenda/api/builder/protoc.sh"

if [ $? -ne 0 ]; then
exit 1
fi
16 changes: 16 additions & 0 deletions api/builder/protoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,41 @@ PROTO_DIR="${API_DIR}/proto"
GRPC_DIR="${API_DIR}/grpc"
mkdir -p "${GRPC_DIR}"

if [ $? -ne 0 ]; then
exit 1
fi

protoc -I "${PROTO_DIR}" \
--go_out="${GRPC_DIR}" \
--go_opt=paths=source_relative \
--go-grpc_out="${GRPC_DIR}" \
--go-grpc_opt=paths=source_relative \
"${PROTO_DIR}"/**/*.proto

if [ $? -ne 0 ]; then
exit 1
fi

# Build protobufs in the disperser/api/proto directory.

DISPERSER_DIR="$SCRIPT_DIR/../../disperser"
DISPERSER_PROTO_DIR="$DISPERSER_DIR/api/proto"
DISPERSER_GRPC_DIR="$DISPERSER_DIR/api/grpc"
mkdir -p "${DISPERSER_GRPC_DIR}"

if [ $? -ne 0 ]; then
exit 1
fi

protoc -I "${DISPERSER_PROTO_DIR}" -I "${PROTO_DIR}" \
--go_out="${DISPERSER_GRPC_DIR}" \
--go_opt=paths=source_relative \
--go-grpc_out="${DISPERSER_GRPC_DIR}" \
--go-grpc_opt=paths=source_relative \
"${DISPERSER_PROTO_DIR}"/**/*.proto

if [ $? -ne 0 ]; then
exit 1
fi

set -x

0 comments on commit 4f6e25b

Please sign in to comment.