Skip to content

Commit cb51db9

Browse files
committed
Add CICD workflow for generated files
1 parent e150385 commit cb51db9

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

.github/workflows/generated-files.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Generated files
2+
3+
on: [workflow_call]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
generate:
10+
runs-on: ubuntu-latest
11+
env:
12+
PROTO_VER: "29.3"
13+
PROTOC_GEN_GO_VER: "1.28.1"
14+
PROTOC_GEN_GO_GRPC_VER: "1.2.0"
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version-file: 'go.work'
20+
- name: Install dependencies
21+
run: |
22+
# Install protoc
23+
wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTO_VER}/protoc-${PROTO_VER}-linux-x86_64.zip
24+
sudo unzip -d /usr/local protoc-${PROTO_VER}-linux-x86_64.zip
25+
export PATH=$PATH:/usr/local/bin
26+
27+
# Install protoc-gen-go
28+
go install google.golang.org/protobuf/cmd/protoc-gen-go@v${PROTOC_GEN_GO_VER}
29+
30+
# Install protoc-gen-go-grpc
31+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${PROTOC_GEN_GO_GRPC_VER}
32+
33+
- name: Run generate command
34+
run: make generate
35+
- name: Check diff
36+
run: |
37+
if ! git diff --exit-code; then
38+
echo
39+
echo "❌ Unexpected changes in generated files!"
40+
echo "Run 'make generate` and commit the changes."
41+
exit 1
42+
fi

.github/workflows/pull-request.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ jobs:
1818
uses: ./.github/workflows/lint.yml
1919
integrity-check:
2020
uses: ./.github/workflows/pr-go-integrity.yml
21+
generated-files:
22+
uses: ./.github/workflows/generated-files.yml
2123
out-of-order-migrations:
2224
uses: ./.github/workflows/out-of-order-migrations.yml
2325
unit-tests:
2426
needs: [ integrity-check ]
2527
uses: ./.github/workflows/pr-tests.yml
2628
integration-tests:
27-
needs: [ lint, integrity-check, out-of-order-migrations ]
29+
needs: [ lint, integrity-check, out-of-order-migrations, generated-files ]
2830
uses: ./.github/workflows/integration_tests.yml
2931
publish-test-results:
3032
needs:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ copy-public-builds:
165165

166166

167167
.PHONY: generate
168-
generate: generate/api generate/orchestrator generate/envd generate/db
168+
generate: generate/api generate/orchestrator generate/envd generate/db generate/shared
169169
generate/%:
170170
@echo "Generating code for *$(notdir $@)*"
171171
$(MAKE) -C packages/$(notdir $@) generate

packages/shared/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ generate-models:
1212
@go generate ./pkg/generate_models.go
1313
@echo "Done"
1414

15+
.PHONY: generate
16+
generate: generate-fc generate-models
17+
1518
.PHONY: build-base-template
1619
build-base-template:
1720
@echo "Building base template..."

0 commit comments

Comments
 (0)