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

Use protoc 3.19.5 and protoc-gen-go 1.26.0 #126

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/lyft/protoc-gen-star
name: protoc version 3.17.0
name: protoc version 3.19.5
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -25,7 +25,7 @@ jobs:
with:
go-version: '1.17'
- run: mkdir -p $GOPATH/bin
- run: wget "https://github.com/protocolbuffers/protobuf/releases/download/v3.17.0/protoc-3.17.0-linux-x86_64.zip" -O /tmp/protoc.zip
- run: wget "https://github.com/protocolbuffers/protobuf/releases/download/v3.19.5/protoc-3.19.5-linux-x86_64.zip" -O /tmp/protoc.zip
- run: unzip /tmp/protoc.zip -d /tmp
- run: sudo mv /tmp/bin/protoc /usr/local/bin/protoc
- run: sudo mv /tmp/include/google /usr/local/include/google
Expand Down
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# the name of this package
PKG := $(shell go list .)
PROTOC_VER := $(shell protoc --version | cut -d' ' -f2)
PGG_VER := $(shell protoc-gen-go --version | cut -d' ' -f2 | cut -c 2- )

.PHONY: bootstrap
bootstrap: testdata # set up the project for development

.PHONY: quick
quick: testdata # runs all tests without the race detector or coverage
ifeq ($(PROTOC_VER), 3.17.0)
ifeq ($(PROTOC_VER), 3.19.5)
go test $(PKGS) --tags=proto3_presence
else
go test $(PKGS)
endif

.PHONY: tests
tests: testdata # runs all tests against the package with race detection and coverage percentage
ifeq ($(PROTOC_VER), 3.17.0)
ifeq ($(PROTOC_VER), 3.19.5)
go test -race -cover ./... --tags=proto3_presence
else
go test -race -cover ./...
endif

.PHONY: cover
cover: testdata # runs all tests against the package, generating a coverage report and opening it in the browser
ifeq ($(PROTOC_VER), 3.17.0)
ifeq ($(PROTOC_VER), 3.19.5)
go test -race -covermode=atomic -coverprofile=cover.out ./... --tags=proto3_presence || true
else
go test -race -covermode=atomic -coverprofile=cover.out ./... || true
Expand All @@ -40,16 +41,15 @@ docs: # starts a doc server and opens a browser window to this package
testdata: testdata-graph testdata-go testdata/generated testdata/fdset.bin # generate all testdata

.PHONY: testdata-graph
testdata-graph: bin/protoc-gen-debug # parses the proto file sets in testdata/graph and renders binary CodeGeneratorRequest
testdata-graph: # parses the proto file sets in testdata/graph and renders binary CodeGeneratorRequest
set -e; for subdir in `find ./testdata/graph -mindepth 1 -maxdepth 1 -type d`; do \
protoc -I ./testdata/graph \
--plugin=protoc-gen-debug=./bin/protoc-gen-debug \
--debug_out="$$subdir:$$subdir" \
`find $$subdir -name "*.proto"`; \
done

testdata/generated: protoc-gen-go bin/protoc-gen-example
go install google.golang.org/protobuf/cmd/protoc-gen-go
testdata/generated: bin/protoc-gen-example
rm -rf ./testdata/generated && mkdir -p ./testdata/generated
# generate the official go code, must be one directory at a time
set -e; for subdir in `find ./testdata/protos -mindepth 1 -type d`; do \
Expand All @@ -74,19 +74,22 @@ testdata/fdset.bin:
testdata/protos/**/*.proto

.PHONY: testdata-go
testdata-go: protoc-gen-go bin/protoc-gen-debug # generate go-specific testdata
testdata-go: # generate go-specific testdata
cd lang/go && $(MAKE) \
testdata-names \
testdata-packages \
testdata-outputs
ifeq ($(PROTOC_VER), 3.17.0)
ifeq ($(PROTOC_VER), 3.19.5)
cd lang/go && $(MAKE) \
testdata-presence
endif

.PHONY: protoc-gen-go
protoc-gen-go:
ifeq ($(PGG_VER), 1.26.0)
else
go install google.golang.org/protobuf/cmd/protoc-gen-go
endif

bin/protoc-gen-example: # creates the demo protoc plugin for demonstrating uses of PG*
go build -o ./bin/protoc-gen-example ./testdata/protoc-gen-example
Expand Down
4 changes: 2 additions & 2 deletions field.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Field interface {

// InRealOneOf returns true if the field is in a OneOf of the parent Message.
// This will return false for synthetic oneofs, and will only include 'real' oneofs.
// See: https://github.com/protocolbuffers/protobuf/blob/v3.17.0/docs/field_presence.md
// See: https://github.com/protocolbuffers/protobuf/blob/v3.19.5/docs/field_presence.md
InRealOneOf() bool

// OneOf returns the OneOf that this field is a part of. Nil is returned if
Expand All @@ -33,7 +33,7 @@ type Field interface {
Type() FieldType

// HasPresence returns true for all fields that have explicit presence as defined by:
// See: https://github.com/protocolbuffers/protobuf/blob/v3.17.0/docs/field_presence.md
// See: https://github.com/protocolbuffers/protobuf/blob/v3.19.5/docs/field_presence.md
HasPresence() bool

// HasOptionalKeyword returns whether the field is labeled as optional.
Expand Down
2 changes: 1 addition & 1 deletion init_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func BiDirectional() InitOption {
}

// SupportedFeatures allows defining protoc features to enable / disable.
// See: https://github.com/protocolbuffers/protobuf/blob/v3.17.0/docs/implementing_proto3_presence.md#signaling-that-your-code-generator-supports-proto3-optional
// See: https://github.com/protocolbuffers/protobuf/blob/v3.19.5/docs/implementing_proto3_presence.md#signaling-that-your-code-generator-supports-proto3-optional
func SupportedFeatures(feat *uint64) InitOption {
return func(g *Generator) {
g.persister.SetSupportedFeatures(feat)
Expand Down
2 changes: 1 addition & 1 deletion lang/go/testdata/names/keyword/keyword.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax="proto3";

package names.keyword;
option go_package = "example.com/package";
option go_package = "example.com/package;package";

message Package {}
2 changes: 1 addition & 1 deletion lang/go/testdata/names/path_dash/path_dash.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax="proto3";
package names.path_dash;
option go_package="example.com/path-dash";
option go_package="example.com/path-dash;path_dash";

message PathDash {}
4 changes: 2 additions & 2 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ type Message interface {
OneOfFields() []Field

// SyntheticOneOfFields returns only the fields contained within synthetic OneOf blocks.
// See: https://github.com/protocolbuffers/protobuf/blob/v3.17.0/docs/field_presence.md
// See: https://github.com/protocolbuffers/protobuf/blob/v3.19.5/docs/field_presence.md
SyntheticOneOfFields() []Field

// OneOfs returns the OneOfs contained within this Message.
OneOfs() []OneOf

// RealOneOfs returns the OneOfs contained within this Message.
// This excludes synthetic OneOfs.
// See: https://github.com/protocolbuffers/protobuf/blob/v3.17.0/docs/field_presence.md
// See: https://github.com/protocolbuffers/protobuf/blob/v3.19.5/docs/field_presence.md
RealOneOfs() []OneOf

// Extensions returns all of the Extensions applied to this Message.
Expand Down
2 changes: 1 addition & 1 deletion oneof.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type OneOf interface {
Fields() []Field

// IsSynthetic returns true if this is a proto3 synthetic oneof.
// See: https://github.com/protocolbuffers/protobuf/blob/v3.17.0/docs/field_presence.md
// See: https://github.com/protocolbuffers/protobuf/blob/v3.19.5/docs/field_presence.md
IsSynthetic() bool

setMessage(m Message)
Expand Down
2 changes: 1 addition & 1 deletion proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
// Proto3 syntax permits the use of "optional" field presence. Non optional fields default to the zero
// value of that particular type if not defined.
// Most of the field types in the generated go structs are value types.
// See: https://github.com/protocolbuffers/protobuf/blob/v3.17.0/docs/field_presence.md#presence-in-proto3-apis
// See: https://github.com/protocolbuffers/protobuf/blob/v3.19.5/docs/field_presence.md#presence-in-proto3-apis
Proto3 Syntax = "proto3"
)

Expand Down
Loading