From 08be1ce7ec96104905b65322d3da340249055a50 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sat, 27 Dec 2025 23:23:17 -0800 Subject: [PATCH] build: pass GOFLAGS to docker to support buildvcs=false In trying to develop the KYAML support, various tests gave false positive results because they made assumptions about Git functionality Make it possible to avoid that by passing GOFLAGS='-buildvcs=false' to to Makefile. Signed-off-by: Robin H. Johnson --- CONTRIBUTING.md | 15 +++++++++++++++ Makefile | 1 + Makefile.variables | 2 ++ project-words.txt | 1 + 4 files changed, 19 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 39b883de..9d058a56 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -197,6 +197,21 @@ Note: PRs with small changes (e.g. minor typos) may not be merged (see https://j make [local] test # Run in Docker container ``` +- **Problem**: Tests fail with a VCS error: + ```bash + error obtaining VCS status: exit status 128 + Use -buildvcs=false to disable VCS stamping. + ``` +- **Solution**: + Git security mechanisms prevent Golang from detecting the Git details inside + the container; either build with the `local` option, or pass GOFLAGS to + disable Golang buildvcs behaviour. + ```bash + make local test + # OR + make test GOFLAGS='-buildvcs=true' + ``` + ### Documentation Generation Issues - **Problem**: Generated docs don't update after test changes - **Solution**: diff --git a/Makefile b/Makefile index e50cdd48..41083d4a 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ clean: ## prefix before other make targets to run in your local dev environment local: | quiet @$(eval ENGINERUN= ) + @$(eval GOFLAGS="$(GOFLAGS)" ) @mkdir -p tmp @touch tmp/dev_image_id quiet: # this is silly but shuts up 'Nothing to be done for `local`' diff --git a/Makefile.variables b/Makefile.variables index 110cea72..d0cb0820 100644 --- a/Makefile.variables +++ b/Makefile.variables @@ -4,6 +4,7 @@ IMPORT_PATH := github.com/mikefarah/${PROJECT} export GIT_COMMIT = $(shell git rev-parse --short HEAD) export GIT_DIRTY = $(shell test -n "$$(git status --porcelain)" && echo "+CHANGES" || true) export GIT_DESCRIBE = $(shell git describe --tags --always) +GOFLAGS := LDFLAGS := LDFLAGS += -X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} LDFLAGS += -X main.GitDescribe=${GIT_DESCRIBE} @@ -33,6 +34,7 @@ DEV_IMAGE := ${PROJECT}_dev ENGINERUN := ${ENGINE} run --rm \ -e LDFLAGS="${LDFLAGS}" \ + -e GOFLAGS="${GOFLAGS}" \ -e GITHUB_TOKEN="${GITHUB_TOKEN}" \ -v ${ROOT}/vendor:/go/src${SELINUX} \ -v ${ROOT}:/${PROJECT}/src/${IMPORT_PATH}${SELINUX} \ diff --git a/project-words.txt b/project-words.txt index 794d4678..a7f5b54c 100644 --- a/project-words.txt +++ b/project-words.txt @@ -291,3 +291,4 @@ KYAML nokyaml buildvcs behaviour +GOFLAGS