...
1#!/bin/bash
2
3set -ex # Exit on error; debugging enabled.
4set -o pipefail # Fail a pipe if any sub-command fails.
5
6# - Source them sweet sweet helpers.
7source "$(dirname $0)/vet-common.sh"
8
9# - Check to make sure it's safe to modify the user's git repo.
10git status --porcelain | fail_on_output
11
12# - Undo any edits made by this script.
13cleanup() {
14 git reset --hard HEAD
15}
16trap cleanup EXIT
17
18# - Installs protoc into your ${GOBIN} directory, if requested.
19# ($GOBIN might not be the best place for the protoc binary, but is at least
20# consistent with the place where all binaries installed by scripts in this repo
21# go.)
22if [[ "$1" = "-install" ]]; then
23 if [[ "${GITHUB_ACTIONS}" = "true" ]]; then
24 PROTOBUF_VERSION=25.2 # Shows up in pb.go files as v4.22.0
25 PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
26 pushd /home/runner/go
27 wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME}
28 unzip ${PROTOC_FILENAME}
29 protoc --version # Check that the binary works.
30 popd
31 else
32 # TODO: replace with install protoc when https://github.com/grpc/grpc-go/pull/7064 is merged.
33 die "-install currently intended for use in CI only."
34 fi
35 echo SUCCESS
36 exit 0
37elif [[ "$#" -ne 0 ]]; then
38 die "Unknown argument(s): $*"
39fi
40
41# - Check that generated proto files are up to date.
42go generate google.golang.org/grpc/... && git status --porcelain 2>&1 | fail_on_output || \
43(git status; git --no-pager diff; exit 1)
44
45echo SUCCESS
46exit 0
View as plain text