Skip to content

Commit 4f278b6

Browse files
authored
fix(ci): detect generated API missing (#412)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 01432f0 commit 4f278b6

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

.github/workflows/test.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,24 @@ jobs:
5050
# Check that the generated ent code is up to date
5151
# see https://entgo.io/docs/ci/
5252
- uses: ent/contrib/ci@e38dfb6484dfbe64b8bd060fe6a219a1aa5da770 # master
53-
name: "Check all generated code is checked in"
53+
name: "Check all ent generated code is checked in"
5454
if: ${{ matrix.app != 'main-module' }}
5555
with:
5656
working-directory: app/${{ matrix.app }}
5757

58+
# Check that the generated API code is up to date
59+
# We install the tools and run the protoc generation before checking differences
60+
- name: "Check all API generated code is checked in"
61+
if: ${{ matrix.app == 'main-module' }}
62+
run: |
63+
make init-api-tools
64+
make api
65+
if [ -n "$(git status --porcelain)" ]; then
66+
echo "Error: The Git repository is dirty (has uncommitted changes). Make sure all the generated API-related files are checked in."
67+
git status --porcelain
68+
exit 1
69+
fi
70+
5871
- name: Test
5972
if: ${{ matrix.app != 'main-module' }}
6073
run: make -C app/${{ matrix.app }} test

app/artifact-cas/api/cas/v1/status_http.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/api/controlplane/v1/status_http.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common.mk

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@ VERSION=$(shell git describe --tags --always)
22

33
.PHONY: init
44
# init env
5-
init:
6-
go install google.golang.org/protobuf/cmd/[email protected]
7-
go install google.golang.org/grpc/cmd/[email protected]
8-
go install github.com/envoyproxy/[email protected]
9-
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@latest
10-
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest
5+
init: init-api-tools
116
go install github.com/google/wire/cmd/wire@latest
127
go install github.com/vektra/mockery/[email protected]
138
go install ariga.io/atlas/cmd/[email protected]
9+
10+
# initialize API tooling
11+
.PHONY: init-api-tools
12+
init-api-tools:
13+
go install google.golang.org/protobuf/cmd/[email protected]
14+
go install google.golang.org/grpc/cmd/[email protected]
1415
go install github.com/bufbuild/buf/cmd/[email protected]
16+
go install github.com/envoyproxy/[email protected]
17+
# Tools fixed to a specific version via its commit since they are not released standalone
18+
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/[email protected]
19+
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/[email protected]
1520

1621
# show help
1722
help:

0 commit comments

Comments
 (0)