generated from giantswarm/template-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
477a4de
commit de7b61e
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.PHONY: fmt | ||
fmt: ## Run go fmt against code. | ||
go fmt ./... | ||
|
||
.PHONY: vet | ||
vet: ## Run go vet against code. | ||
go vet ./... | ||
|
||
.PHONY: test-unit | ||
test-unit: ginkgo generate fmt vet envtest ## Run unit tests | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GINKGO) -p --nodes 4 -r -randomize-all --randomize-suites --skip-package=tests --cover --coverpkg=`go list ./... | grep -v fakes | tr '\n' ','` ./... | ||
|
||
.PHONY: test-all | ||
test-all: test-unit ## Run all tests | ||
|
||
.PHONY: coverage-html | ||
coverage-html: test-unit | ||
go tool cover -html coverprofile.out | ||
|
||
ENVTEST = $(shell pwd)/bin/setup-envtest | ||
.PHONY: envtest | ||
envtest: ## Download envtest-setup locally if necessary. | ||
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) | ||
|
||
GINKGO = $(shell pwd)/bin/ginkgo | ||
.PHONY: ginkgo | ||
ginkgo: ## Download ginkgo locally if necessary. | ||
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo@latest) | ||
|
||
DOCKER_COMPOSE = $(shell pwd)/bin/docker-compose | ||
.PHONY: docker-compose | ||
docker-compose: ## Download docker-compose locally if necessary. | ||
$(eval LATEST_RELEASE = $(shell curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.tag_name')) | ||
curl -sL "https://github.com/docker/compose/releases/download/$(LATEST_RELEASE)/docker-compose-linux-x86_64" -o $(DOCKER_COMPOSE) | ||
chmod +x $(DOCKER_COMPOSE) | ||
|
||
local: | ||
./hack/bin/run-local.sh | ||
|
||
# go-get-tool will 'go get' any package $2 and install it to $1. | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
define go-get-tool | ||
@[ -f $(1) ] || { \ | ||
set -e ;\ | ||
TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
echo "Downloading $(2)" ;\ | ||
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ | ||
rm -rf $$TMP_DIR ;\ | ||
} | ||
endef |