google.golang.org/grpc@v1.72.2/scripts/vet-proto.sh (about) 1 #!/bin/bash 2 3 set -ex # Exit on error; debugging enabled. 4 set -o pipefail # Fail a pipe if any sub-command fails. 5 6 # - Source them sweet sweet helpers. 7 source "$(dirname $0)/common.sh" 8 9 # - Check to make sure it's safe to modify the user's git repo. 10 git status --porcelain | fail_on_output 11 12 # - Undo any edits made by this script. 13 cleanup() { 14 git reset --hard HEAD 15 } 16 trap 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.) 22 if [[ "$1" = "-install" ]]; then 23 if [[ "${GITHUB_ACTIONS}" = "true" ]]; then 24 source ./scripts/install-protoc.sh "/home/runner/go" 25 else 26 die "run protoc installer https://github.com/grpc/grpc-go/blob/master/scripts/install-protoc.sh" 27 fi 28 echo SUCCESS 29 exit 0 30 elif [[ "$#" -ne 0 ]]; then 31 die "Unknown argument(s): $*" 32 fi 33 34 for MOD_FILE in $(find . -name 'go.mod'); do 35 MOD_DIR=$(dirname ${MOD_FILE}) 36 pushd ${MOD_DIR} 37 go generate ./... 38 popd 39 done 40 41 # - Check that generated proto files are up to date. 42 git status --porcelain 2>&1 | fail_on_output || \ 43 (git status; git --no-pager diff; exit 1) 44 45 echo SUCCESS 46 exit 0