Skip to content

Commit

Permalink
generate protobuf in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Oct 4, 2024
1 parent 14a18df commit f4a942e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ jobs:
- name: Run "make generate" and check for changes
run: |
set -e
apt install protobuf-compiler
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
make generate 2>/dev/null
if [[ $(git status --porcelain) ]]; then
echo "Error: Uncommitted changes found after running 'make generate'. Please commit all generated code."
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ generate: ## Generate code for the database and APIs
$(GO) generate ./pkg/database/ent
$(GO) generate ./pkg/models
$(GO) generate ./pkg/modelscapi
# TODO: install the protoc-gen-go plugin in CI
# $(GO) generate ./pkg/protobufs
$(GO) generate ./pkg/protobufs

.PHONY: testclean
testclean: bats-clean ## Remove test artifacts
Expand Down
11 changes: 9 additions & 2 deletions pkg/protobufs/generate.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package protobufs

// Dependencies:
//
// apt install protobuf-compiler
// go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
// go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
//
// keep this in sync with go.mod
// go install google.golang.org/protobuf/cmd/[email protected]
//
// Not the same versions as google.golang.org/grpc
// go list -m -versions google.golang.org/grpc/cmd/protoc-gen-go-grpc
// go install google.golang.org/grpc/cmd/[email protected].

//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative notifier.proto

0 comments on commit f4a942e

Please sign in to comment.