tests: Set GIT_CONFIG_GLOBAL=/dev/null for tests run via make test

This ensures that no host specific git configuration is pulled in while
testing. One such example would be "init.defaultBranch" which is set to
"main" on some hosts, which then causes tests to fail as they keep looking
for "master" branches.

Signed-off-by: Alexander Block <ablock84@gmail.com>
This commit is contained in:
Alexander Block 2022-04-25 14:20:45 +02:00
parent cfbe6ac124
commit 7c8b175258
1 changed files with 2 additions and 0 deletions

View File

@ -96,6 +96,7 @@ build: check-deps $(LIBGIT2) ## Build manager binary
KUBEBUILDER_ASSETS?="$(shell $(ENVTEST) --arch=$(ENVTEST_ARCH) use -i $(ENVTEST_KUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR) -p path)"
test: $(LIBGIT2) install-envtest test-api check-deps ## Run tests
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) \
GIT_CONFIG_GLOBAL=/dev/null \
go test $(GO_STATIC_FLAGS) ./... -coverprofile cover.out
check-deps:
@ -268,3 +269,4 @@ env: $(LIBGIT2)
echo 'CGO_CFLAGS="$(CGO_CFLAGS)"' >> $(BUILD_DIR)/.env
echo 'CGO_LDFLAGS="$(CGO_LDFLAGS)"' >> $(BUILD_DIR)/.env
echo 'KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS)' >> $(BUILD_DIR)/.env
echo 'GIT_CONFIG_GLOBAL=/dev/null' >> $(BUILD_DIR)/.env