From 1d3de149473ac08218cc27886053d43a64d35e75 Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Tue, 14 Jun 2022 20:19:16 +0100 Subject: [PATCH] build: enable -race for go test Signed-off-by: Paulo Gomes --- .github/workflows/build.yaml | 7 +++++++ Makefile | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1e0a93f1..a647fa5c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -44,6 +44,13 @@ jobs: go-version: 1.17.x - name: Run tests run: make test + env: + # Temporarily disabling -race for arm64 as our GitHub action + # runners don't seem to like it. + # + # We should reenable go test -race for arm64 runners once the + # current issue is resolved. + GO_TEST_ARGS: "" - name: Verify run: make verify diff --git a/Makefile b/Makefile index d18292ae..d10a93f8 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,9 @@ BUILD_ARGS ?= # Architectures to build images for BUILD_PLATFORMS ?= linux/amd64,linux/arm64,linux/arm/v7 +# Allows for defining additional Go test args, e.g. '-tags integration'. +GO_TEST_ARGS ?= -race + # Directory with versioned, downloaded things CACHE := cache @@ -138,10 +141,10 @@ endif KUBEBUILDER_ASSETS?="$(shell $(ENVTEST) --arch=$(ENVTEST_ARCH) use -i $(ENVTEST_KUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR) -p path)" test: $(LIBGIT2) tidy test-api test_deps generate fmt vet manifests api-docs install-envtest ## Run tests KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) \ - go test $(GO_STATIC_FLAGS) ./... -coverprofile cover.out + go test $(GO_STATIC_FLAGS) $(GO_TEST_ARGS) ./... -coverprofile cover.out test-api: ## Run api tests - cd api; go test ./... -coverprofile cover.out + cd api; go test $(GO_TEST_ARGS) ./... -coverprofile cover.out manager: $(LIBGIT2) generate fmt vet ## Build manager binary go build -o $(BUILD_DIR)/bin/manager ./main.go