-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vet: split vet-proto from vet.sh (#7099)
- Loading branch information
Showing
6 changed files
with
71 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
fail_on_output() { | ||
tee /dev/stderr | not read | ||
} | ||
|
||
# not makes sure the command passed to it does not exit with a return code of 0. | ||
not() { | ||
# This is required instead of the earlier (! $COMMAND) because subshells and | ||
# pipefail don't work the same on Darwin as in Linux. | ||
! "$@" | ||
} | ||
|
||
die() { | ||
echo "$@" >&2 | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
set -ex # Exit on error; debugging enabled. | ||
set -o pipefail # Fail a pipe if any sub-command fails. | ||
|
||
# - Source them sweet sweet helpers. | ||
source "$(dirname $0)/vet-common.sh" | ||
|
||
# - Check to make sure it's safe to modify the user's git repo. | ||
git status --porcelain | fail_on_output | ||
|
||
# - Undo any edits made by this script. | ||
cleanup() { | ||
git reset --hard HEAD | ||
} | ||
trap cleanup EXIT | ||
|
||
# - Installs protoc into your ${GOBIN} directory, if requested. | ||
# ($GOBIN might not be the best place for the protoc binary, but is at least | ||
# consistent with the place where all binaries installed by scripts in this repo | ||
# go.) | ||
if [[ "$1" = "-install" ]]; then | ||
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then | ||
PROTOBUF_VERSION=25.2 # Shows up in pb.go files as v4.22.0 | ||
PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip | ||
pushd /home/runner/go | ||
wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME} | ||
unzip ${PROTOC_FILENAME} | ||
protoc --version # Check that the binary works. | ||
popd | ||
else | ||
# TODO: replace with install protoc when https://github.com/grpc/grpc-go/pull/7064 is merged. | ||
die "-install currently intended for use in CI only." | ||
fi | ||
echo SUCCESS | ||
exit 0 | ||
elif [[ "$#" -ne 0 ]]; then | ||
die "Unknown argument(s): $*" | ||
fi | ||
|
||
# - Check that generated proto files are up to date. | ||
go generate google.golang.org/grpc/... && git status --porcelain 2>&1 | fail_on_output || \ | ||
(git status; git --no-pager diff; exit 1) | ||
|
||
echo SUCCESS | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters