Skip to content

Commit

Permalink
Add test-no-verify target
Browse files Browse the repository at this point in the history
Check for uncommitted changes in code and fail if it needs to
  • Loading branch information
razo7 committed Feb 16, 2023
1 parent 85ac12c commit dd1fabe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ go-verify: go-tidy go-vendor # Run go mod verify - verify dependencies have expe
go mod verify

.PHONY: test
test: manifests generate go-verify fmt vet envtest ## Run tests.
test: test-no-verify verify-unchanged ## Generate and format code, run tests, generate manifests and bundle, and verify no uncommitted changes

.PHONY: test-no-verify
test-no-verify: manifests generate go-verify fmt vet envtest # Generate and format code, and run tests
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out

##@ Build
Expand All @@ -175,7 +178,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker-build: test-no-verify ## Build docker image with the manager.
docker build -t ${IMG} .

.PHONY: docker-push
Expand Down Expand Up @@ -325,6 +328,10 @@ catalog-push: ## Push a catalog image.

##@ Targets used by CI

.PHONY: verify-unchanged
verify-unchanged: ## Verify there are no un-committed changes
./hack/verify-unchanged.sh

.PHONY: container-build
container-build: docker-build bundle-build ## Build containers

Expand Down
7 changes: 7 additions & 0 deletions hack/verify-unchanged.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [[ -n "$(git status --porcelain .)" ]]; then
echo "Uncommitted generated files. Run 'make check' and commit results."
echo "$(git status --porcelain .)"
exit 1
fi

0 comments on commit dd1fabe

Please sign in to comment.