Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: run go generate during ci builds to check all files updated #2372

Merged
merged 1 commit into from Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .circleci/config.yml
Expand Up @@ -14,6 +14,14 @@ commands:
name: Run gofmt
command: ./gofmt.sh

# gogenerate validates that any generated code has been updated if needed.
gogenerate:
steps:
- checkout
- run:
name: Check generated code
command: ./gogenerate.sh

# govet does govet checks in the entire codebase.
govet:
steps:
Expand Down Expand Up @@ -144,6 +152,7 @@ jobs:
- install_go_deps
- check_go_deps
- gofmt
- gogenerate
- govet
- staticcheck

Expand Down
17 changes: 17 additions & 0 deletions gogenerate.sh
@@ -0,0 +1,17 @@
#! /bin/bash
set -e

# Check if go-bindata is installed, if not install it.
command -v go-bindata >/dev/null 2>&1 || (
dir=$(mktemp -d)
pushd $dir
go mod init tool
go get github.com/kevinburke/go-bindata/go-bindata@v3.18.0+incompatible
popd
)

printf "Running go generate...\n"
go generate ./...

printf "Checking for no diff...\n"
git diff --exit-code || (echo "Files changed after running go generate. Run go generate ./... locally and update generated files." && exit 1)