Skip to content

Commit

Permalink
feat: add test and lint cmd to makefiles (#2176)
Browse files Browse the repository at this point in the history
Signed-off-by: Griffin <prakritimandal611@gmail.com>
  • Loading branch information
prakrit55 committed Sep 29, 2023
1 parent 2b5267c commit c55e0a9
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ install-prometheus:
kubectl wait --for=condition=available deployment/kube-state-metrics -n monitoring --timeout=120s
kubectl wait pod/prometheus-k8s-0 --for=condition=ready --timeout=120s -n monitoring

.PHONY: metrics-operator-test
metrics-operator-test:
$(MAKE) -C metrics-operator test

.PHONY: certmanager-test
certmanager-test:
$(MAKE) -C klt-cert-manager test

.PHONY: operator-test
operator-test:
$(MAKE) -C lifecycle-operator test

.PHONY: scheduler-test
scheduler-test:
$(MAKE) -C scheduler test

#command(make test) to run all tests
.PHONY: test
test: metrics-operator-test certmanager-test operator-test scheduler-test integration-test

.PHONY: cleanup-manifests
cleanup-manifests:
rm -rf manifests
Expand Down Expand Up @@ -111,3 +131,25 @@ include docs/Makefile

yamllint:
@docker run --rm -t -v $(PWD):/data cytopia/yamllint:$(YAMLLINT_VERSION) .

##Run lint for the subfiles
.PHONY: metrics-operator-lint
metrics-operator-lint:
$(MAKE) -C metrics-operator lint

.PHONY: certmanager-lint
certmanager-lint:
$(MAKE) -C klt-cert-manager lint

.PHONY: operator-lint
operator-lint:
$(MAKE) -C lifecycle-operator lint

.PHONY: scheduler-lint
scheduler-lint:
$(MAKE) -C scheduler lint

.PHONY: lint
lint:
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
metrics-operator-lint certmanager-lint operator-lint scheduler-lint
8 changes: 8 additions & 0 deletions klt-cert-manager/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ vet: ## Run go vet against code.
unit-test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out

#command(make test) to run all tests
.PHONY: test
test: unit-test
##@ Build

.PHONY: build
Expand Down Expand Up @@ -187,3 +190,8 @@ push-local:
release-manifests:
kustomize build config/default > config/rendered/release.yaml
envsubst < config/rendered/release.yaml > tmp.yaml; mv tmp.yaml config/rendered/release.yaml

##golangci-lint
.PHONY: lint
lint:
${GOPATH}/bin/golangci-lint run --config ../.golangci.yml -v
9 changes: 9 additions & 0 deletions lifecycle-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ performance-test: manifests generate envtest ## Run tests.
e2e-test: manifests generate envtest ## Run tests.
go test ./test/e2e -v -coverprofile cover.out --ginkgo.focus="E2E"

#command(make test) to run all tests
.PHONY: test
test: unit-test component-test performance-test e2e-test

##@ Build
.PHONY: build
build: generate ## Build manager binary.
Expand Down Expand Up @@ -244,3 +248,8 @@ push-local:
docker push $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)-arm64 ;\
fi
docker push $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)

##golangci-lint
.PHONY: lint
lint:
${GOPATH}/bin/golangci-lint run --config ../.golangci.yml -v
9 changes: 9 additions & 0 deletions metrics-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ vet: ## Run go vet against code.
unit-test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out

#command(make test) to run all tests
.PHONY: test
test: unit-test

##@ Build
.PHONY: build
build: generate ## Build manager binary.
Expand Down Expand Up @@ -205,3 +209,8 @@ push-local:
docker push $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)-arm64 ;\
fi
docker push $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)

##golangci-lint
.PHONY: lint
lint:
${GOPATH}/bin/golangci-lint run --config ../.golangci.yml -v
9 changes: 9 additions & 0 deletions scheduler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ unit-test: manifests fmt vet envtest## Run tests.
cat cover-main.out cover-pkg.out >> cover.out
rm cover-pkg.out cover-main.out

#command(make test) to run all tests
.PHONY: test
test: e2e-test unit-test


.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down Expand Up @@ -172,3 +176,8 @@ push-local:
docker push $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)-arm64 ;\
fi
docker push $(RELEASE_REGISTRY)/$(RELEASE_IMAGE)

##golangci-lint
.PHONY: lint
lint:
${GOPATH}/bin/golangci-lint run --config ../.golangci.yml -v

0 comments on commit c55e0a9

Please sign in to comment.