Skip to content

Commit 4558b68

Browse files
ci: add check to verify generated code is up-to-date (#258)
This commit adds a new CI job that runs code generation and verifies no uncommitted changes exist. This prevents accidental manual edits to autogenerated files by: 1. Running `go generate ./...` during CI 2. Failing the build when generated code differs from committed code 3. Providing clear error messages with instructions for developers
1 parent dd1e1e8 commit 4558b68

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
branches:
55
- main
66
pull_request:
7+
workflow_dispatch:
8+
79
jobs:
810
test:
911
runs-on: ubuntu-latest
@@ -13,3 +15,21 @@ jobs:
1315
with:
1416
go-version-file: 'go.mod'
1517
- run: go test ./... -race
18+
19+
verify-codegen:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-go@v5
24+
with:
25+
go-version-file: 'go.mod'
26+
- name: Run code generation
27+
run: go generate ./...
28+
- name: Check for uncommitted changes
29+
run: |
30+
if [[ -n $(git status --porcelain) ]]; then
31+
echo "Error: Generated code is not up to date. Please run 'go generate ./...' and commit the changes."
32+
git status
33+
git diff
34+
exit 1
35+
fi

0 commit comments

Comments
 (0)