Skip to content

Commit

Permalink
feat(template): update buf integration from v1beta1 to v1 (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielzwink authored Mar 25, 2022
1 parent c7332a7 commit d833ae5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 34 deletions.
27 changes: 7 additions & 20 deletions _template/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,32 +95,19 @@ endef
# this creates a target for each go dependency to be referenced in other targets
$(foreach dep, $(GO_DEPENDENCIES), $(eval $(call make-go-dependency, $(dep))))

api/proto/google:
@mkdir -p api/proto/google/api
curl -s https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto -o api/proto/google/api/annotations.proto
curl -s https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto -o api/proto/google/api/http.proto
curl -s https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/field_behavior.proto -o api/proto/google/api/field_behavior.proto
.PHONY: api/proto/buf.lock
api/proto/buf.lock: bin/buf
@bin/buf mod update api/proto

api/proto/validate:
@mkdir -p api/proto/validate
curl -s https://raw.githubusercontent.com/envoyproxy/protoc-gen-validate/main/validate/validate.proto -o api/proto/validate/validate.proto

{{- if .Extensions.grpc.grpcGateway }}
api/proto/protoc-gen-openapiv2:
@mkdir -p api/proto/protoc-gen-openapiv2/options
curl -s https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/protoc-gen-openapiv2/options/openapiv2.proto -o api/proto/protoc-gen-openapiv2/options/openapiv2.proto
curl -s https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/protoc-gen-openapiv2/options/annotations.proto -o api/proto/protoc-gen-openapiv2/options/annotations.proto
{{- end }}

protolint: bin/buf bin/protoc-gen-buf-lint ## Lints your protobuf files
protolint: api/proto/buf.lock bin/protoc-gen-buf-lint ## Lints your protobuf files
bin/buf lint

protobreaking: bin/buf bin/protoc-gen-buf-breaking ## Compares your current protobuf with the version on master to find breaking changes
protobreaking: api/proto/buf.lock bin/protoc-gen-buf-breaking ## Compares your current protobuf with the version on master to find breaking changes
bin/buf breaking --against '.git#branch=master'

generate: ## Generates code from protobuf files
generate: api/proto/google api/proto/validate {{if .Extensions.grpc.grpcGateway}}api/proto/protoc-gen-openapiv2 bin/protoc-gen-grpc-gateway bin/protoc-gen-openapiv2{{end}} bin/buf bin/protoc-gen-go bin/protoc-gen-go-grpc bin/protoc-gen-validate
PATH=$(PWD)/bin:$$PATH buf generate --path api/proto/{{.Base.appName}}/v1/{{.Base.appName}}.proto
generate: {{if .Extensions.grpc.grpcGateway}}bin/protoc-gen-grpc-gateway bin/protoc-gen-openapiv2{{end}} api/proto/buf.lock bin/protoc-gen-go bin/protoc-gen-go-grpc bin/protoc-gen-validate
PATH=$(PWD)/bin:$$PATH buf generate
{{- end }}

ci: lint-reports test-reports ## Executes lint and test and generates reports
Expand Down
23 changes: 10 additions & 13 deletions _template/buf.yaml → _template/api/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
version: v1beta1
build:
roots:
- api/proto
lint:
version: v1
breaking:
use:
- DEFAULT
ignore:
- google
- validate
- FILE
deps:
- buf.build/envoyproxy/protoc-gen-validate
- buf.build/googleapis/googleapis
{{- if .Extensions.grpc.grpcGateway }}
- protoc-gen-openapiv2
- buf.build/grpc-ecosystem/grpc-gateway
{{- end }}
lint:
use:
- DEFAULT
except:
- RPC_RESPONSE_STANDARD_NAME
- RPC_REQUEST_RESPONSE_UNIQUE
breaking:
use:
- FILE
2 changes: 1 addition & 1 deletion _template/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: v1beta1
version: v1
plugins:
- name: go
out: internal/pkg/api/pb
Expand Down
3 changes: 3 additions & 0 deletions _template/buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1
directories:
- api/proto

0 comments on commit d833ae5

Please sign in to comment.