From a70174a621150aa14c4df281db0b8df8a5014e61 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 4 Jul 2023 16:55:16 +0900 Subject: [PATCH 1/2] Direct gotest target to test ... to reduce almost duplicate targets. Also, remove the test target from github workflow because now the test is executed in prow. --- .github/workflows/golangci-lint.yaml | 4 +--- Makefile | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 4d8c4ffc..dbff9283 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: test: - name: github (govet, golint and gotest) + name: github (govet and golint) runs-on: ubuntu-latest steps: - name: Install Go @@ -22,8 +22,6 @@ jobs: run: ./openstack-k8s-operators-ci/test-runner/govet.sh - name: Run golint.sh run: ./openstack-k8s-operators-ci/test-runner/golint.sh - - name: Run tests - run: make test golangci: name: github (golangci) diff --git a/Makefile b/Makefile index 28eebde6..bb4bf4fe 100644 --- a/Makefile +++ b/Makefile @@ -291,10 +291,7 @@ govet: get-ci-tools GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/govet.sh ./api # Run go test against code -gotest: envtest get-ci-tools - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" - GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/gotest.sh KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" - GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/gotest.sh ./api +gotest: test # Run golangci-lint test against code golangci: get-ci-tools From 57eb2126613dfd8f01b007a35a49c16a4b86f8d8 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 5 Jul 2023 04:38:54 +0900 Subject: [PATCH 2/2] Replace go test by ginkgo --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bb4bf4fe..4e416564 100644 --- a/Makefile +++ b/Makefile @@ -102,8 +102,8 @@ vet: ## Run go vet against code. go vet ./... .PHONY: test -test: manifests generate fmt vet envtest ## Run tests. - OPERATOR_TEMPLATES=./templates KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -v ./... -coverprofile cover.out +test: manifests generate fmt vet envtest ginkgo ## Run tests. + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) --trace --cover --coverpkg=../../pkg/horizon,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./tests/... ##@ Build @@ -179,6 +179,7 @@ $(LOCALBIN): KUSTOMIZE ?= $(LOCALBIN)/kustomize CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest +GINKGO ?= $(LOCALBIN)/ginkgo ## Tool Versions KUSTOMIZE_VERSION ?= v3.8.7 @@ -200,6 +201,11 @@ envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. $(ENVTEST): $(LOCALBIN) test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest +.PHONY: ginkgo +ginkgo: $(GINKGO) ## Download ginkgo locally if necessary. +$(GINKGO): $(LOCALBIN) + test -s $(LOCALBIN)/ginkgo || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo + .PHONY: bundle bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files. operator-sdk generate kustomize manifests -q