Skip to content

Commit

Permalink
Verify generated files are up to date in merge check (#3007)
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers authored Feb 3, 2023
1 parent c94ffd3 commit a32c2a6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ helm-lint:
${MAKEFILE_PATH}/test/helm/helm-lint.sh

# Generate code
.PHONY: generate
generate: aws-sdk-model-override controller-gen mockgen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
MOCKGEN=$(MOCKGEN) ./scripts/gen_mocks.sh
Expand Down Expand Up @@ -161,9 +162,13 @@ lint:
echo "TODO"

.PHONY: quick-ci
quick-ci: verify-versions
quick-ci: verify-versions verify-generate
echo "Done!"

.PHONY: verify-generate
verify-generate:
hack/verify-generate.sh

.PHONY: verify-versions
verify-versions:
hack/verify-versions.sh
Expand Down
32 changes: 32 additions & 0 deletions hack/verify-generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

make generate

changed_files=$(git status --porcelain --untracked-files=no || true)
if [ -n "${changed_files}" ]; then
echo "Detected that generated code is not up to date; run 'make generate'"
echo "changed files:"
printf "%s\n" "${changed_files}"
echo "git diff:"
git --no-pager diff
echo "To fix: run 'make generate'"
exit 1
fi

0 comments on commit a32c2a6

Please sign in to comment.