Skip to content

Commit

Permalink
Check that generated files are up to date (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz authored and kensipe committed Dec 31, 2019
1 parent e7244b3 commit b4a92ba
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.sum" }}
# prebuild runs lint after code generation
- run: make prebuild
- run: make lint
- run: ./hack/verify-generate.sh
- save_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
Expand Down
25 changes: 25 additions & 0 deletions hack/verify-generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -o nounset
set -o pipefail
# intentionally not setting 'set -o errexit' because we want to print custom error messages

# make sure make generate can be invoked
make generate
RETVAL=$?
if [[ ${RETVAL} != 0 ]]; then
echo "Invoking 'make generate' ends with non-zero exit code."
exit 1
fi

git diff --exit-code --quiet
RETVAL=$?

if [[ ${RETVAL} != 0 ]]; then
echo "Running 'make generate' produces changes to the current git status. Maybe you forgot to check-in your updated generated files?"
echo "The current diff: `git diff`"
exit 1
fi

echo "Verifying 'make generate' was successful! ヽ(•‿•)ノ"
exit 0

0 comments on commit b4a92ba

Please sign in to comment.