Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/protoc-gen-go-grpc: add change detector test #7072

Merged
merged 23 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ jobs:

# Run the main gRPC-Go tests.
tests:
# Proto checks are run in the above job.
env:
VET_SKIP_PROTO: 1
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
Expand Down Expand Up @@ -98,7 +95,9 @@ jobs:
# Only run vet for 'vet' runs.
- name: Run vet.sh
if: matrix.type == 'vet'
run: ./vet.sh -install && ./vet.sh
run: |
VET_SKIP_PROTO=1
./vet.sh -install && ./vet.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think these can fit on one line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know of a clean one line way to apply VET_SKIP_PROTO to both ./vet.sh commands

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ... you need it set for both? :(

If you're interested, I've been meaning to delete VET_SKIP_PROTO and instead make it the default, with VET_CHECK_PROTO=1 set if you actually what to check the proto files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. I can send a follow for that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7099

-- I'll actually wait for that to merge before merging this PR


# Main tests run for everything except when testing "extras"
# (where we run a reduced set of tests).
Expand Down Expand Up @@ -128,3 +127,8 @@ jobs:
interop/interop_test.sh
echo -e "\n-- Running xDS E2E Test --"
xds/internal/test/e2e/run.sh
echo -e "\n-- Running protoc-gen-go-grpc change detector test --"
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
./vet.sh -install
(cd test/tools && go install google.golang.org/protobuf/cmd/protoc-gen-go)
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
(cd cmd/protoc-gen-go-grpc && go install .)
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
cmd/protoc-gen-go-grpc/protoc-gen-go-grpc_test.sh
2 changes: 1 addition & 1 deletion cmd/protoc-gen-go-grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ change from the grpc code generator previously included with `protoc-gen-go`.
To restore this behavior, set the option `require_unimplemented_servers=false`.
E.g.:

```
```sh
protoc --go-grpc_out=. --go-grpc_opt=require_unimplemented_servers=false[,other options...] \
```

Expand Down
34 changes: 34 additions & 0 deletions cmd/protoc-gen-go-grpc/proto/golden.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

option go_package = "testdata/proto";
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved

package main;

message EventRequest {
bytes content = 1;
}

message EventResponse {
bytes content = 1;
}

service BidirectionalStreamingService {
rpc unaryMethod(EventRequest) returns (EventResponse) {}
rpc clientMethod(stream EventRequest) returns (EventResponse) {}
rpc serverMethod(EventRequest) returns (stream EventResponse) {};
rpc bidirectionalMethod(stream EventRequest) returns (stream EventResponse) {}
}
25 changes: 25 additions & 0 deletions cmd/protoc-gen-go-grpc/protoc-gen-go-grpc_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -ex # Debugging enabled.

die() {
echo "$@" >&2
exit 1
}

trap "git clean --force --quiet" EXIT

WD="$(dirname $0)"

protoc \
--go_out=. \
--go_opt=paths=source_relative \
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
--go-grpc_out=. \
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
--go-grpc_opt=paths=source_relative \
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
"$WD/proto/golden.proto"

if !(diff -u "$WD/testdata/golden_grpc.pb.go" "$WD/proto/golden_grpc.pb.go"); then
die "Generated file golden_grpc.pb.go differs from golden file; If you have made recent changes to protoc-gen-go-grpc, please regenerate the golden files."
fi

echo SUCCESS
Loading
Loading