Skip to content

Commit 0b7bf32

Browse files
authored
fix: skip helm chart tests when helm is not installed (#788)
* fix: skip helm chart tests when helm is not installed Signed-off-by: Vivek Karunai Kiri Ragavan <vkarunai@redhat.com> * fix: auto-download helm in Makefile when not present Signed-off-by: Vivek Karunai Kiri Ragavan <vkarunai@redhat.com> --------- Signed-off-by: Vivek Karunai Kiri Ragavan <vkarunai@redhat.com>
1 parent 9659b8d commit 0b7bf32

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ vet: ## Run go vet against code.
8989
go vet ./...
9090

9191
.PHONY: test
92-
test: manifests generate fmt vet setup-envtest ## Run tests.
93-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
92+
test: manifests generate fmt vet setup-envtest helm ## Run tests.
93+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" PATH=$(LOCALBIN):$(PATH) go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
9494

9595
# Creates a multi-node Kind cluster
9696
# Adds emulated GPU labels and capacities per node
@@ -398,6 +398,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
398398
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
399399
ENVTEST ?= $(LOCALBIN)/setup-envtest
400400
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
401+
HELM ?= $(LOCALBIN)/helm
401402

402403
## Tool Versions
403404
KUSTOMIZE_VERSION ?= v5.6.0
@@ -407,6 +408,7 @@ ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller
407408
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
408409
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
409410
GOLANGCI_LINT_VERSION ?= v2.8.0
411+
HELM_VERSION ?= v3.17.1
410412

411413
.PHONY: kustomize
412414
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -472,6 +474,17 @@ $(GOLANGCI_LINT): $(LOCALBIN)
472474
} ;\
473475
ln -sf golangci-lint-$(GOLANGCI_LINT_VERSION) $(GOLANGCI_LINT)
474476

477+
.PHONY: helm
478+
helm: $(HELM) ## Download helm locally if necessary.
479+
$(HELM): $(LOCALBIN)
480+
@[ -f "$(LOCALBIN)/helm-$(HELM_VERSION)" ] || { \
481+
set -e; \
482+
echo "Downloading helm $(HELM_VERSION)"; \
483+
curl -sSfL https://get.helm.sh/helm-$(HELM_VERSION)-$(shell go env GOOS)-$(shell go env GOARCH).tar.gz | tar xz --no-same-owner -C $(LOCALBIN) --strip-components=1 $(shell go env GOOS)-$(shell go env GOARCH)/helm; \
484+
mv $(LOCALBIN)/helm $(LOCALBIN)/helm-$(HELM_VERSION); \
485+
} ;\
486+
ln -sf helm-$(HELM_VERSION) $(HELM)
487+
475488
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
476489
# $1 - target path with name of binary
477490
# $2 - package url which can be installed

0 commit comments

Comments
 (0)