Skip to content

Commit

Permalink
Add CI check that auto-generated code is up to date (#1828)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Aug 16, 2023
1 parent eea64af commit b5da142
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/auto-generated-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Auto-Generated Code Checker
on:
push:
tags:
- "*"
branches:
- master
- dev
pull_request:

jobs:
protobuf_codegen:
name: Protobuf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '~1.19.12'
check-latest: true
- uses: bufbuild/buf-setup-action@v1.23.1
- shell: bash
run: scripts/protobuf_codegen.sh
- shell: bash
run: .github/workflows/check-clean-branch.sh
mock_gen:
name: Mocks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '~1.19.12'
check-latest: true
- shell: bash
run: scripts/mock.gen.sh
- shell: bash
run: .github/workflows/check-clean-branch.sh
9 changes: 9 additions & 0 deletions .github/workflows/check-clean-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Exits if any uncommitted changes are found.

set -o errexit
set -o nounset
set -o pipefail

git update-index --really-refresh >> /dev/null
git diff-index --quiet HEAD
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ To regenerate the protobuf go code, run `scripts/protobuf_codegen.sh` from the r

This should only be necessary when upgrading protobuf versions or modifying .proto definition files.

To use this script, you must have [buf](https://docs.buf.build/installation) (v1.23.1), protoc-gen-go (v1.28.0) and protoc-gen-go-grpc (v1.2.0) installed.
To use this script, you must have [buf](https://docs.buf.build/installation) (v1.23.1), protoc-gen-go (v1.30.0) and protoc-gen-go-grpc (v1.3.0) installed.

To install the buf dependencies:

```sh
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
```

If you have not already, you may need to add `$GOPATH/bin` to your `$PATH`:
Expand Down
4 changes: 2 additions & 2 deletions proto/Dockerfile.buf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY --from=builder /usr/local/bin/buf /usr/local/bin/

# any version changes here should also be bumped in scripts/protobuf_codegen.sh
RUN \
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 && \
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0 && \
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0

ENV PATH="${PATH}:/root/go/bin/"

0 comments on commit b5da142

Please sign in to comment.