Skip to content

Commit

Permalink
Fix verification of generated files
Browse files Browse the repository at this point in the history
Firstly, we weren't checking the go workspace in hack/codegen.

Secondly, we weren't verifying generated files in the orc directory at
all.
  • Loading branch information
mdbooth authored and k8s-infra-cherrypick-robot committed Oct 18, 2024
1 parent eefb044 commit 66520b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ modules: ## Runs go mod to ensure proper vendoring.
$(MAKE) -C $(REPO_ROOT)/orc modules
go mod tidy
cd $(TOOLS_DIR); go mod tidy
cd $(REPO_ROOT)/hack/codegen; go mod tidy
cd $(REPO_ROOT)/hack/codegen; go work sync; go mod tidy

.PHONY: generate
generate: templates generate-orc generate-controller-gen generate-codegen generate-conversion-gen generate-go generate-manifests generate-api-docs ## Generate all generated code
Expand Down Expand Up @@ -540,25 +540,30 @@ clean-release: ## Remove the release folder
rm -rf $(RELEASE_DIR)

.PHONY: verify
verify: verify-boilerplate verify-modules verify-gen
verify: verify-boilerplate verify-modules verify-gen verify-orc

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

.PHONY: verify-modules
verify-modules: modules
@if !(git diff --quiet HEAD -- go.sum go.mod hack/tools/go.mod hack/tools/go.sum); then \
@if !(git diff --quiet HEAD -- go.* hack/tools/go.* hack/codegen/go.*); then \
git diff; \
echo "go module files are out of date"; exit 1; \
fi

.PHONY: verify-gen
verify-gen: generate
@if !(git diff --quiet HEAD); then \
git diff; \
echo "generated files are out of date, run make generate"; exit 1; \
fi

.PHONY: verify-orc
verify-orc:
$(MAKE) -C $(REPO_ROOT)/orc verify-generated

.PHONY: compile-e2e
compile-e2e: ## Test e2e compilation
go test -c -o /dev/null -tags=e2e ./test/e2e/suites/conformance
Expand Down
11 changes: 9 additions & 2 deletions orc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
.PHONY: modules
modules:
go mod tidy
cd hack/codegen; go mod tidy
cd hack/codegen; go work sync; go mod tidy

.PHONY: generate
generate: manifests generate-controller-gen generate-codegen
generate: modules manifests generate-controller-gen generate-codegen

.PHONY: generate-controller-gen
generate-controller-gen: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand All @@ -63,6 +63,13 @@ generate-controller-gen: controller-gen ## Generate code containing DeepCopy, De
generate-codegen: generate-controller-gen ## codegen requires DeepCopy etc
./hack/update-codegen.sh

.PHONY: verify-generated
verify-generated: generate
@if !(git diff --quiet HEAD); then \
git diff; \
echo "generated files are out of date, run make generate"; exit 1; \
fi

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
Expand Down

0 comments on commit 66520b0

Please sign in to comment.