Skip to content

Commit

Permalink
Remove vuln from unit-tests
Browse files Browse the repository at this point in the history
There is little value in running vuln in unit-tests. When it complains,
it complains about CVEs in your local Go version, which is
not the same Go binary that will build in CI (we use stable
and oldstable).

The target `git-commit-sha` was a no-op. The logic to determine whether
to add a `-` at the end of the commit SHA was broken, it was always
chosing to add a `-`. Now the `GIT_COMMIT` is always the HEAD commit SHA
+ `-dev` suffix.

Signed-off-by: Aitor Perez Cedres <1515757+Zerpet@users.noreply.github.com>
  • Loading branch information
Zerpet committed May 28, 2024
1 parent 09c2f56 commit f13f359
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,27 @@ $(KUBEBUILDER_ASSETS):

.PHONY: unit-tests
unit-tests::install-tools ## Run unit tests
unit-test::$(KUBEBUILDER_ASSETS)
unit-test::generate
unit-test::fmt
unit-test::vet
unit-test::vuln
unit-test::manifests
unit-test::just-unit-tests
unit-tests::$(KUBEBUILDER_ASSETS)
unit-tests::generate
unit-tests::fmt
unit-tests::vet
unit-tests::manifests
unit-tests::just-unit-tests

.PHONY: just-unit-tests
just-unit-tests:
ginkgo -r --randomize-all api/ internal/ rabbitmqclient/

.PHONY: integration-tests
integration-tests: install-tools $(KUBEBUILDER_ASSETS) generate fmt vet manifests ## Run integration tests. Use GINKGO_EXTRA="-some-arg" to append arguments to 'ginkgo run'
ginkgo -r --randomize-all -p $(GINKGO_EXTRA) controllers/

just-integration-tests: $(KUBEBUILDER_ASSETS) vet
integration-tests::install-tools ## Run integration tests. Use GINKGO_EXTRA="-some-arg" to append arguments to 'ginkgo run'
integration-tests::$(KUBEBUILDER_ASSETS)
integration-tests::generate
integration-tests::fmt
integration-tests::vet
integration-tests::manifests
integration-tests::just-integration-tests

just-integration-tests: $(KUBEBUILDER_ASSETS)
ginkgo --randomize-all -r -p $(GINKGO_EXTRA) controllers/

local-tests: unit-tests integration-tests ## Run all local tests (unit & integration)
Expand Down Expand Up @@ -169,7 +173,9 @@ ifndef DOCKER_REGISTRY_SECRET
$(error DOCKER_REGISTRY_SECRET is undefined: Name of Kubernetes secret in which to store the Docker registry username and password)
endif

docker-build-dev: check-env-docker-repo git-commit-sha
GIT_COMMIT=$(shell git rev-parse --short HEAD)-dev

docker-build-dev: check-env-docker-repo
$(BUILD_KIT) buildx build --build-arg=GIT_COMMIT=$(GIT_COMMIT) -t $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT) .
$(BUILD_KIT) push $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT)

Expand All @@ -178,13 +184,6 @@ docker-registry-secret: check-env-docker-credentials operator-namespace
@kubectl -n $(K8S_OPERATOR_NAMESPACE) create secret docker-registry $(DOCKER_REGISTRY_SECRET) --docker-server='$(DOCKER_REGISTRY_SERVER)' --docker-username="$$DOCKER_REGISTRY_USERNAME" --docker-password="$$DOCKER_REGISTRY_PASSWORD" || true
@kubectl -n $(K8S_OPERATOR_NAMESPACE) patch serviceaccount messaging-topology-operator -p '{"imagePullSecrets": [{"name": "$(DOCKER_REGISTRY_SECRET)"}]}'

git-commit-sha:
ifeq ("", git diff --stat)
GIT_COMMIT=$(shell git rev-parse --short HEAD)
else
GIT_COMMIT=$(shell git rev-parse --short HEAD)-
endif

check-env-registry-server:
ifndef DOCKER_REGISTRY_SERVER
$(error DOCKER_REGISTRY_SERVER is undefined: URL of docker registry containing the Operator image (e.g. registry.my-company.com))
Expand Down

0 comments on commit f13f359

Please sign in to comment.