From 13b3c404d01b17dfda0d2a759d6ab1667f81cf52 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Tue, 20 Jan 2026 19:20:35 -0800 Subject: [PATCH 01/19] feat(go): add support for Go subprojects --- .mise/tasks/stencil/post/go-sync | 11 +++----- shell/lib/go.sh | 17 ++++++++++++ shell/lib/go_test.bats | 45 ++++++++++++++++++++++++++++++++ shell/linters/go.sh | 45 ++++++++++++++++++++++---------- 4 files changed, 97 insertions(+), 21 deletions(-) create mode 100644 shell/lib/go.sh create mode 100644 shell/lib/go_test.bats diff --git a/.mise/tasks/stencil/post/go-sync b/.mise/tasks/stencil/post/go-sync index 5b501fea..90c53283 100755 --- a/.mise/tasks/stencil/post/go-sync +++ b/.mise/tasks/stencil/post/go-sync @@ -11,6 +11,9 @@ DEVBASE_LIB_DIR="$DEVBASE_ROOT_DIR/shell/lib" # shellcheck source=../../../../shell/lib/bootstrap.sh source "$DEVBASE_LIB_DIR"/bootstrap.sh +# shellcheck source=../../../../shell/lib/go.sh +source "$DEVBASE_LIB_DIR"/go.sh + # shellcheck source=../../../../shell/lib/logging.sh source "$DEVBASE_LIB_DIR"/logging.sh @@ -39,16 +42,10 @@ if [[ -z $gomodGoVersion ]]; then exit 0 fi -git ls-files '**/go.mod' | while read -r gomod; do +go_mod_dirs | while read -r gomod; do if managed_by_stencil "$gomod"; then continue fi - for ignored in ${IGNORED_GO_MOD_DIRS:-}; do - if [[ "$(dirname "$gomod")" == "$ignored" ]]; then - warn "Ignoring $gomod as per IGNORED_GO_MOD_DIRS" - continue 2 - fi - done info "Syncing Go version/toolchain in $gomod to $gomodGoVersion/$goVersion" sed_replace '^go .*$' "go $gomodGoVersion" "$appDir/$gomod" diff --git a/shell/lib/go.sh b/shell/lib/go.sh new file mode 100644 index 00000000..1d8362b6 --- /dev/null +++ b/shell/lib/go.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# Go-related utility functions. + +# Retrieve list of directories containing go.mod files in the repository. +# Use the IGNORED_GO_MOD_DIRS environment variable (space-separated +# directories) to skip specific directories. +go_mod_dirs() { + git ls-files --cached --others --modified --exclude-standard go.mod '**/go.mod' | xargs dirname | while read -r gomodDir; do + for ignored in ${IGNORED_GO_MOD_DIRS:-}; do + if [[ $gomodDir == "$ignored" ]]; then + continue 2 + fi + done + echo "$gomodDir" + done | sort | uniq | xargs echo +} diff --git a/shell/lib/go_test.bats b/shell/lib/go_test.bats new file mode 100644 index 00000000..4a6833c3 --- /dev/null +++ b/shell/lib/go_test.bats @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +bats_load_library "bats-support/load.bash" +bats_load_library "bats-assert/load.bash" + +load go.sh +load test_helper.sh + +setup() { + # This points us to use a temp file for a git repo to operate on, as + # opposed to the real one. + REPOPATH=$(mktempdir devbase-lib-go-XXXXXX) + + git init --initial-branch=main "$REPOPATH" + cd "$REPOPATH" || exit 1 + git config user.name "Test User" + git config user.email "testuser@example.com" +} + +teardown() { + rm -rf "$REPOPATH" +} + +@test "go_mod_dirs finds all go.mod files in the repo" { + mkdir -p moduleA moduleB/submodule + touch moduleA/go.mod + touch moduleB/submodule/go.mod + touch go.mod + + run go_mod_dirs + assert_success + assert_output ". moduleA moduleB/submodule" +} + +@test "go_mod_dirs excludes go.mod files in IGNORED_GO_MOD_DIRS" { + mkdir -p moduleA moduleB/submodule moduleC + touch moduleA/go.mod + touch moduleB/submodule/go.mod + touch moduleC/go.mod + touch go.mod + + IGNORED_GO_MOD_DIRS="moduleB/submodule moduleC" run go_mod_dirs + assert_success + assert_output ". moduleA" # output is sorted +} diff --git a/shell/linters/go.sh b/shell/linters/go.sh index c11956d2..505151b7 100644 --- a/shell/linters/go.sh +++ b/shell/linters/go.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash # Linters for Golang +# shellcheck source=../lib/go.sh +source "$DIR/lib/go.sh" + # Why: Used by the script that calls us # shellcheck disable=SC2034 extensions=("go") @@ -24,11 +27,18 @@ gofumpt() { } linter() { - run_command "go mod tidy" go mod tidy -diff || return 1 - # gofmt/goimports/gofumpt checking is done by golangci-lint - run_command "golangci-lint" \ - "$DIR/golangci-lint.sh" --build-tags "or_e2e,or_test" --timeout 10m run ./... || return 1 - run_command "lintroller" lintroller || return 1 + for godir in $(go_mod_dirs); do + pushd "$godir" >/dev/null || return 1 + if [[ $godir != "." ]]; then + info "Linting module in $godir" + fi + run_command "go mod tidy" go mod tidy -diff || return 1 + # gofmt/goimports/gofumpt checking is done by golangci-lint + run_command "golangci-lint" \ + "$DIR/golangci-lint.sh" --build-tags "or_e2e,or_test" --timeout 10m run ./... || return 1 + run_command "lintroller" lintroller || return 1 + popd >/dev/null || return 1 + done } formatter() { @@ -37,13 +47,20 @@ formatter() { if [[ -f "$(get_repo_directory)/go.work" ]]; then run_command "go work use" go work use || return 1 fi - run_command "go mod tidy" go mod tidy || return 1 - if [[ -z $goFormatter || $goFormatter == "null" || $goFormatter == "gofmt" ]]; then - run_command goimports goimports || return 1 - run_command gofmt gofmt || return 1 - elif [[ $goFormatter == gofumpt ]]; then - run_command gofumpt gofumpt || return 1 - else - fatal "Unknown Go formatter: $goFormatter" - fi + for godir in $(go_mod_dirs); do + pushd "$godir" >/dev/null || return 1 + if [[ $godir != "." ]]; then + info "Formatting module in $godir" + fi + run_command "go mod tidy" go mod tidy || return 1 + if [[ -z $goFormatter || $goFormatter == "null" || $goFormatter == "gofmt" ]]; then + run_command goimports goimports || return 1 + run_command gofmt gofmt || return 1 + elif [[ $goFormatter == gofumpt ]]; then + run_command gofumpt gofumpt || return 1 + else + fatal "Unknown Go formatter: $goFormatter" + fi + popd >/dev/null || return 1 + done } From 34852c63e5acb15c64b7faf9e61178996a79fb32 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 09:19:37 -0800 Subject: [PATCH 02/19] feat(test): add support for multiple go.mod folders --- shell/test.sh | 82 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/shell/test.sh b/shell/test.sh index 79d1d646..6a63d006 100755 --- a/shell/test.sh +++ b/shell/test.sh @@ -11,6 +11,9 @@ source "$DIR/lib/bootstrap.sh" # shellcheck source=./lib/github.sh source "$DIR/lib/github.sh" +# shellcheck source=./lib/go.sh +source "$DIR/lib/go.sh" + # shellcheck source=./lib/logging.sh source "$DIR/lib/logging.sh" @@ -116,12 +119,60 @@ e2e_go_toolchain() { echo "$toolchain+auto" } +go_ldflags() { + echo "-X github.com/getoutreach/go-outreach/v2/pkg/app.Version=testing -X github.com/getoutreach/gobox/pkg/app.Version=testing" +} + +run_tests() { + local projectDir="$1" + pushd "$projectDir" >/dev/null || fatal "Failed to change directory to $projectDir" + info "Running go test (${TEST_TAGS[*]}) in $projectDir" + local exitCode=0 + + local junitFile + if [[ $projectDir == "." ]]; then + junitFile="$REPODIR/bin/unit-tests.xml" + else + # Replace path separators with dashes for the junit file name + local sanitizedDir + sanitizedDir="$(echo "$projectDir" | tr '/\' '--')" + junitFile="$REPODIR/bin/unit-tests-${sanitizedDir}.xml" + fi + + ( + if [[ ${TEST_TAGS[*]} =~ "or_e2e" ]]; then + # Workaround from https://github.com/golang/go/issues/75031#issuecomment-3195256688 + local toolchain + toolchain="$(e2e_go_toolchain)" + go env -w GOTOOLCHAIN="$toolchain" + info_sub "Running E2E tests with Go toolchain $toolchain" + fi + mise_exec_tool gotestsum --junitfile "$junitFile" --format "$format" -- \ + "${BENCH_FLAGS[@]}" "${COVER_FLAGS[@]}" "${TEST_FLAGS[@]}" \ + -ldflags "$(go_ldflags)" -tags="$test_tags_string" "$@" "${TEST_PACKAGES[@]}" + ) || exitCode=$? + + if in_ci_environment; then + # Move this to a temporary directory so that we can control + # what gets uploaded via the store_test_results call + mv "$junitFile" /tmp/test-results/ + fi + + if [[ $exitCode -ne 0 ]]; then + error "Tests failed in $projectDir with exit code $exitCode" + exit $exitCode + fi + popd >/dev/null || fatal "Failed to change directory back from $projectDir" +} + if in_ci_environment; then GOFLAGS+=(-mod=readonly) WITH_COVERAGE="true" # Ensure that all processes recieve the value of GOFLAGS. export GOFLAGS + # Coverage results directory + mkdir -p /tmp/test-results fi # If GO_TEST_TIMEOUT is set, we pass it to `go test` as a timeout. @@ -160,8 +211,6 @@ if [[ -e $testInclude ]]; then fi if [[ "$(git ls-files '*_test.go' | wc -l | tr -d ' ')" -gt 0 ]]; then - info "Running go test (${TEST_TAGS[*]})" - format="dots-v2" if in_ci_environment; then # When in CI, always use the pkgname format because it's easier to @@ -201,36 +250,15 @@ if [[ "$(git ls-files '*_test.go' | wc -l | tr -d ' ')" -gt 0 ]]; then # complex linker flags very well right now (v1.7.3). go test -c -o "${TESTBIN}" \ "${BENCH_FLAGS[@]}" "${COVER_FLAGS[@]}" "${TEST_FLAGS[@]}" \ - -ldflags "-X github.com/getoutreach/go-outreach/v2/pkg/app.Version=testing -X github.com/getoutreach/gobox/pkg/app.Version=testing" \ - -tags="$test_tags_string" "$PACKAGE_TO_DEBUG" + -ldflags "$(go_ldflags)" -tags="$test_tags_string" "$PACKAGE_TO_DEBUG" # We pass along command line args to the executable so you can specify # `-test.run `, `-test.bench `, etc. if desired. Try `-help` # for more information. exec "$DIR/dlv.sh" exec "${TESTBIN}" -- "$@" else - exitCode=0 - - ( - if [[ ${TEST_TAGS[*]} =~ "or_e2e" ]]; then - # Workaround from https://github.com/golang/go/issues/75031#issuecomment-3195256688 - toolchain="$(e2e_go_toolchain)" - go env -w GOTOOLCHAIN="$toolchain" - info_sub "Running E2E tests with Go toolchain $toolchain" - fi - mise_exec_tool gotestsum --junitfile "$REPODIR/bin/unit-tests.xml" --format "$format" -- \ - "${BENCH_FLAGS[@]}" "${COVER_FLAGS[@]}" "${TEST_FLAGS[@]}" \ - -ldflags "-X github.com/getoutreach/go-outreach/v2/pkg/app.Version=testing -X github.com/getoutreach/gobox/pkg/app.Version=testing" \ - -tags="$test_tags_string" "$@" "${TEST_PACKAGES[@]}" - ) || exitCode=$? - - if in_ci_environment; then - # Move this to a temporary directory so that we can control - # what gets uploaded via the store_test_results call - mkdir -p /tmp/test-results - mv "$REPODIR/bin/unit-tests.xml" /tmp/test-results/ - fi - - exit $exitCode + for godir in $(go_mod_dirs); do + run_tests "$godir" || fatal "Tests failed in $godir" + done fi fi From 460db9d8f270fcef2ecf03ac03170bd37cda91c3 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 09:23:40 -0800 Subject: [PATCH 03/19] Fix AI autocomplete hallucination --- shell/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/test.sh b/shell/test.sh index 6a63d006..d2a5e889 100755 --- a/shell/test.sh +++ b/shell/test.sh @@ -135,7 +135,7 @@ run_tests() { else # Replace path separators with dashes for the junit file name local sanitizedDir - sanitizedDir="$(echo "$projectDir" | tr '/\' '--')" + sanitizedDir="$(echo "$projectDir" | tr '/' '--')" junitFile="$REPODIR/bin/unit-tests-${sanitizedDir}.xml" fi From 74120f5e2e9d89788b3c4608fad816a290ae5e9f Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 09:35:48 -0800 Subject: [PATCH 04/19] Convert e2e_go_toolchain to be multi-go.mod aware --- shell/test.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/shell/test.sh b/shell/test.sh index d2a5e889..af26af61 100755 --- a/shell/test.sh +++ b/shell/test.sh @@ -105,14 +105,17 @@ SHUFFLE="${SHUFFLE:-enabled}" # is "standard-verbose". TEST_OUTPUT_FORMAT="${TEST_OUTPUT_FORMAT:-}" +# repoDir is the base directory of the repository. +repoDir=$(get_repo_directory) + # Generates the Go toolchain string to be used for E2E tests. # Go 1.25 and later have an issue with code coverage, so we append # "+auto" so that the `covdata` tool is available. # See: https://github.com/golang/go/issues/75031 e2e_go_toolchain() { - local repoDir toolchain - repoDir="$(get_repo_directory)" - toolchain="$(grep ^toolchain "$repoDir/go.mod" | awk '{print $2}')" + local goDir="$1" + local toolchain + toolchain="$(grep ^toolchain "$goDir/go.mod" | awk '{print $2}')" if [[ -z $toolchain ]]; then toolchain="go$(grep ^golang "$repoDir/.tool-versions" | awk '{print $2}')" fi @@ -131,19 +134,19 @@ run_tests() { local junitFile if [[ $projectDir == "." ]]; then - junitFile="$REPODIR/bin/unit-tests.xml" + junitFile="$repoDir/bin/unit-tests.xml" else # Replace path separators with dashes for the junit file name local sanitizedDir sanitizedDir="$(echo "$projectDir" | tr '/' '--')" - junitFile="$REPODIR/bin/unit-tests-${sanitizedDir}.xml" + junitFile="$repoDir/bin/unit-tests-${sanitizedDir}.xml" fi ( if [[ ${TEST_TAGS[*]} =~ "or_e2e" ]]; then # Workaround from https://github.com/golang/go/issues/75031#issuecomment-3195256688 local toolchain - toolchain="$(e2e_go_toolchain)" + toolchain="$(e2e_go_toolchain "$projectDir")" go env -w GOTOOLCHAIN="$toolchain" info_sub "Running E2E tests with Go toolchain $toolchain" fi @@ -180,9 +183,6 @@ if [[ -n $GO_TEST_TIMEOUT ]]; then TEST_FLAGS+=(-timeout "$GO_TEST_TIMEOUT") fi -# REPODIR is the base directory of the repository. -REPODIR=$(get_repo_directory) - # Catches test dependencies by shuffling tests if the installed Go version supports it currentver="$(go version | awk '{ print $3 }' | sed 's|go||')" requiredver="1.17.0" From a15d902371d395e2747aa379e3d139bfb8b38c70 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 09:36:21 -0800 Subject: [PATCH 05/19] PR changes suggested by AI --- .mise/tasks/stencil/post/go-sync | 2 +- shell/lib/go_test.bats | 1 + shell/test.sh | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.mise/tasks/stencil/post/go-sync b/.mise/tasks/stencil/post/go-sync index 90c53283..20157b6c 100755 --- a/.mise/tasks/stencil/post/go-sync +++ b/.mise/tasks/stencil/post/go-sync @@ -42,7 +42,7 @@ if [[ -z $gomodGoVersion ]]; then exit 0 fi -go_mod_dirs | while read -r gomod; do +for gomod in $(go_mod_dirs); do if managed_by_stencil "$gomod"; then continue fi diff --git a/shell/lib/go_test.bats b/shell/lib/go_test.bats index 4a6833c3..aacfc1ee 100644 --- a/shell/lib/go_test.bats +++ b/shell/lib/go_test.bats @@ -26,6 +26,7 @@ teardown() { touch moduleA/go.mod touch moduleB/submodule/go.mod touch go.mod + git add . run go_mod_dirs assert_success diff --git a/shell/test.sh b/shell/test.sh index af26af61..baaeff23 100755 --- a/shell/test.sh +++ b/shell/test.sh @@ -138,7 +138,7 @@ run_tests() { else # Replace path separators with dashes for the junit file name local sanitizedDir - sanitizedDir="$(echo "$projectDir" | tr '/' '--')" + sanitizedDir="$(echo "$projectDir" | tr '/' '-')" junitFile="$repoDir/bin/unit-tests-${sanitizedDir}.xml" fi @@ -172,7 +172,7 @@ if in_ci_environment; then GOFLAGS+=(-mod=readonly) WITH_COVERAGE="true" - # Ensure that all processes recieve the value of GOFLAGS. + # Ensure that all processes receive the value of GOFLAGS. export GOFLAGS # Coverage results directory mkdir -p /tmp/test-results From 5eac4758c3ba4b40acd36e0ffbcd6e4775ed39e2 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 09:42:05 -0800 Subject: [PATCH 06/19] More AI-suggested fixes --- .mise/tasks/stencil/post/go-sync | 3 ++- shell/lib/go_test.bats | 1 + shell/test.sh | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.mise/tasks/stencil/post/go-sync b/.mise/tasks/stencil/post/go-sync index 20157b6c..8baafdd4 100755 --- a/.mise/tasks/stencil/post/go-sync +++ b/.mise/tasks/stencil/post/go-sync @@ -42,7 +42,8 @@ if [[ -z $gomodGoVersion ]]; then exit 0 fi -for gomod in $(go_mod_dirs); do +for godir in $(go_mod_dirs); do + gomod="$godir/go.mod" if managed_by_stencil "$gomod"; then continue fi diff --git a/shell/lib/go_test.bats b/shell/lib/go_test.bats index aacfc1ee..674b25fc 100644 --- a/shell/lib/go_test.bats +++ b/shell/lib/go_test.bats @@ -39,6 +39,7 @@ teardown() { touch moduleB/submodule/go.mod touch moduleC/go.mod touch go.mod + git add . IGNORED_GO_MOD_DIRS="moduleB/submodule moduleC" run go_mod_dirs assert_success diff --git a/shell/test.sh b/shell/test.sh index baaeff23..bcd649bb 100755 --- a/shell/test.sh +++ b/shell/test.sh @@ -163,7 +163,7 @@ run_tests() { if [[ $exitCode -ne 0 ]]; then error "Tests failed in $projectDir with exit code $exitCode" - exit $exitCode + return $exitCode fi popd >/dev/null || fatal "Failed to change directory back from $projectDir" } From 61ca0d7483d5139dfd1701dddb518a1b88890ceb Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 16:20:49 -0800 Subject: [PATCH 07/19] Pass in extra args correctly --- shell/test.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shell/test.sh b/shell/test.sh index bcd649bb..5560bd3b 100755 --- a/shell/test.sh +++ b/shell/test.sh @@ -126,8 +126,13 @@ go_ldflags() { echo "-X github.com/getoutreach/go-outreach/v2/pkg/app.Version=testing -X github.com/getoutreach/gobox/pkg/app.Version=testing" } -run_tests() { +# run_go_tests [args...] +# +# Runs Go tests with gotestsum for the given project directory, +# with optional additional arguments. +run_go_tests() { local projectDir="$1" + shift pushd "$projectDir" >/dev/null || fatal "Failed to change directory to $projectDir" info "Running go test (${TEST_TAGS[*]}) in $projectDir" local exitCode=0 @@ -258,7 +263,7 @@ if [[ "$(git ls-files '*_test.go' | wc -l | tr -d ' ')" -gt 0 ]]; then exec "$DIR/dlv.sh" exec "${TESTBIN}" -- "$@" else for godir in $(go_mod_dirs); do - run_tests "$godir" || fatal "Tests failed in $godir" + run_go_tests "$godir" "$@" || fatal "Tests failed in $godir" done fi fi From 7e73c0c72f752087d5c7dfc369b13caf46b8b5b5 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 17:28:37 -0800 Subject: [PATCH 08/19] fix(make): run test.sh via mise exec --- root/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/Makefile b/root/Makefile index d9bc26c1..d8a2ee18 100644 --- a/root/Makefile +++ b/root/Makefile @@ -120,7 +120,7 @@ lint:: pre-test pre-lint ## test: run unit tests .PHONY: test test:: pre-test lint - $(BASE_TEST_ENV) ./scripts/shell-wrapper.sh test.sh + $(BASE_TEST_ENV) mise exec -- ./scripts/shell-wrapper.sh test.sh ## test-e2e: run only e2e test (use inside a dev pod) .PHONY: test-e2e From 77ee044da0b8eaa5f2d0cc746205b4abde2c9d60 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 17:43:40 -0800 Subject: [PATCH 09/19] Ensure that env vars from mise.toml are loaded in CI --- shell/test.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell/test.sh b/shell/test.sh index 5560bd3b..5d856cd4 100755 --- a/shell/test.sh +++ b/shell/test.sh @@ -262,6 +262,10 @@ if [[ "$(git ls-files '*_test.go' | wc -l | tr -d ' ')" -gt 0 ]]; then # for more information. exec "$DIR/dlv.sh" exec "${TESTBIN}" -- "$@" else + if in_ci_environment; then + # Ensure that environment variables from mise.toml are loaded + eval "$(mise env --cd "$repoDir" --shell bash)" + fi for godir in $(go_mod_dirs); do run_go_tests "$godir" "$@" || fatal "Tests failed in $godir" done From bdfb8ba7ece9744b582996678b5f8db6190d0f4c Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 18:03:38 -0800 Subject: [PATCH 10/19] Add logging --- shell/lib/go.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/lib/go.sh b/shell/lib/go.sh index 1d8362b6..0ff2ec54 100644 --- a/shell/lib/go.sh +++ b/shell/lib/go.sh @@ -7,11 +7,11 @@ # directories) to skip specific directories. go_mod_dirs() { git ls-files --cached --others --modified --exclude-standard go.mod '**/go.mod' | xargs dirname | while read -r gomodDir; do + info "Ignored go.mod directories: ${IGNORED_GO_MOD_DIRS:-none}" for ignored in ${IGNORED_GO_MOD_DIRS:-}; do if [[ $gomodDir == "$ignored" ]]; then continue 2 fi done - echo "$gomodDir" done | sort | uniq | xargs echo } From 7d6d4cbf7f9179b189bd20617d7f0432eae38d9f Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 18:07:00 -0800 Subject: [PATCH 11/19] log to stderr --- shell/lib/go.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/lib/go.sh b/shell/lib/go.sh index 0ff2ec54..48f11772 100644 --- a/shell/lib/go.sh +++ b/shell/lib/go.sh @@ -7,7 +7,7 @@ # directories) to skip specific directories. go_mod_dirs() { git ls-files --cached --others --modified --exclude-standard go.mod '**/go.mod' | xargs dirname | while read -r gomodDir; do - info "Ignored go.mod directories: ${IGNORED_GO_MOD_DIRS:-none}" + info "Ignored go.mod directories: ${IGNORED_GO_MOD_DIRS:-none}" >&2 for ignored in ${IGNORED_GO_MOD_DIRS:-}; do if [[ $gomodDir == "$ignored" ]]; then continue 2 From 3a46c8fae157f805786dc6a1de74e0ed1852ca20 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 18:10:59 -0800 Subject: [PATCH 12/19] Remove log --- shell/lib/go.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/shell/lib/go.sh b/shell/lib/go.sh index 48f11772..a582bdf1 100644 --- a/shell/lib/go.sh +++ b/shell/lib/go.sh @@ -7,7 +7,6 @@ # directories) to skip specific directories. go_mod_dirs() { git ls-files --cached --others --modified --exclude-standard go.mod '**/go.mod' | xargs dirname | while read -r gomodDir; do - info "Ignored go.mod directories: ${IGNORED_GO_MOD_DIRS:-none}" >&2 for ignored in ${IGNORED_GO_MOD_DIRS:-}; do if [[ $gomodDir == "$ignored" ]]; then continue 2 From af661c22b2352620b465dbac26eee7b2739eac2e Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 18:52:19 -0800 Subject: [PATCH 13/19] Add TODO --- shell/test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/test.sh b/shell/test.sh index 5d856cd4..352b59d3 100755 --- a/shell/test.sh +++ b/shell/test.sh @@ -264,6 +264,7 @@ if [[ "$(git ls-files '*_test.go' | wc -l | tr -d ' ')" -gt 0 ]]; then else if in_ci_environment; then # Ensure that environment variables from mise.toml are loaded + # TODO[DT-5181]: remove this block and re-test once we move `make test` to `mise run test`. eval "$(mise env --cd "$repoDir" --shell bash)" fi for godir in $(go_mod_dirs); do From 52df9dacd0f121b9394507c7209fd988a06987df Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 19:09:53 -0800 Subject: [PATCH 14/19] Fix revert --- shell/lib/go.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/lib/go.sh b/shell/lib/go.sh index a582bdf1..1d8362b6 100644 --- a/shell/lib/go.sh +++ b/shell/lib/go.sh @@ -12,5 +12,6 @@ go_mod_dirs() { continue 2 fi done + echo "$gomodDir" done | sort | uniq | xargs echo } From 4e6db7040d294aad12c409f48dcf05de4f0fdc57 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 19:21:03 -0800 Subject: [PATCH 15/19] Add logging again --- shell/lib/go.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell/lib/go.sh b/shell/lib/go.sh index 1d8362b6..388498b9 100644 --- a/shell/lib/go.sh +++ b/shell/lib/go.sh @@ -7,8 +7,10 @@ # directories) to skip specific directories. go_mod_dirs() { git ls-files --cached --others --modified --exclude-standard go.mod '**/go.mod' | xargs dirname | while read -r gomodDir; do + info "Ignored go.mod directories: ${IGNORED_GO_MOD_DIRS:-none}" >&2 for ignored in ${IGNORED_GO_MOD_DIRS:-}; do if [[ $gomodDir == "$ignored" ]]; then + info_sub "Ignoring go.mod in $gomodDir" >&2 continue 2 fi done From a36dd043ecc5b0b53ae2488d7bbc07c693def9d2 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 19:29:30 -0800 Subject: [PATCH 16/19] Add mise env to linters --- shell/linters.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell/linters.sh b/shell/linters.sh index 9ba54d74..605fa448 100755 --- a/shell/linters.sh +++ b/shell/linters.sh @@ -23,6 +23,9 @@ fi if in_ci_environment; then bootstrap_github_token + # Ensure that environment variables from mise.toml are loaded + # TODO[DT-5181]: remove this block and re-test once we move `make lint` to `mise run lint`. + eval "$(mise env --cd "$repoDir" --shell bash)" else GITHUB_TOKEN="$(github_token)" export GITHUB_TOKEN From 6024158dc5d1708673fd827c22b8438d2d48b4be Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 19:32:52 -0800 Subject: [PATCH 17/19] Fix cd flag --- shell/linters.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/linters.sh b/shell/linters.sh index 605fa448..120f07c7 100755 --- a/shell/linters.sh +++ b/shell/linters.sh @@ -25,7 +25,7 @@ if in_ci_environment; then bootstrap_github_token # Ensure that environment variables from mise.toml are loaded # TODO[DT-5181]: remove this block and re-test once we move `make lint` to `mise run lint`. - eval "$(mise env --cd "$repoDir" --shell bash)" + eval "$(mise env --cd "$(get_repo_directory)" --shell bash)" else GITHUB_TOKEN="$(github_token)" export GITHUB_TOKEN From 63b72f0d2c9b0a7b95f0be1b4d2facc88881b93b Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 20:01:44 -0800 Subject: [PATCH 18/19] Re-remove logging --- shell/lib/go.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/shell/lib/go.sh b/shell/lib/go.sh index 388498b9..1d8362b6 100644 --- a/shell/lib/go.sh +++ b/shell/lib/go.sh @@ -7,10 +7,8 @@ # directories) to skip specific directories. go_mod_dirs() { git ls-files --cached --others --modified --exclude-standard go.mod '**/go.mod' | xargs dirname | while read -r gomodDir; do - info "Ignored go.mod directories: ${IGNORED_GO_MOD_DIRS:-none}" >&2 for ignored in ${IGNORED_GO_MOD_DIRS:-}; do if [[ $gomodDir == "$ignored" ]]; then - info_sub "Ignoring go.mod in $gomodDir" >&2 continue 2 fi done From 8fe8a9ea53eabed05c89719d226b593a1fd6db99 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 25 Feb 2026 20:07:58 -0800 Subject: [PATCH 19/19] Try running scripts under mise exec --- root/Makefile | 2 +- shell/linters.sh | 3 --- shell/test.sh | 5 ----- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/root/Makefile b/root/Makefile index d8a2ee18..42ea3753 100644 --- a/root/Makefile +++ b/root/Makefile @@ -115,7 +115,7 @@ build:: pre-build gobuild lint:: pre-test pre-lint @# Note that this requires the ensure_asdf.sh invocation at the top of @# this file. - $(BASE_TEST_ENV) ./scripts/shell-wrapper.sh linters.sh + $(BASE_TEST_ENV) mise exec -- ./scripts/shell-wrapper.sh linters.sh ## test: run unit tests .PHONY: test diff --git a/shell/linters.sh b/shell/linters.sh index 120f07c7..9ba54d74 100755 --- a/shell/linters.sh +++ b/shell/linters.sh @@ -23,9 +23,6 @@ fi if in_ci_environment; then bootstrap_github_token - # Ensure that environment variables from mise.toml are loaded - # TODO[DT-5181]: remove this block and re-test once we move `make lint` to `mise run lint`. - eval "$(mise env --cd "$(get_repo_directory)" --shell bash)" else GITHUB_TOKEN="$(github_token)" export GITHUB_TOKEN diff --git a/shell/test.sh b/shell/test.sh index 352b59d3..5560bd3b 100755 --- a/shell/test.sh +++ b/shell/test.sh @@ -262,11 +262,6 @@ if [[ "$(git ls-files '*_test.go' | wc -l | tr -d ' ')" -gt 0 ]]; then # for more information. exec "$DIR/dlv.sh" exec "${TESTBIN}" -- "$@" else - if in_ci_environment; then - # Ensure that environment variables from mise.toml are loaded - # TODO[DT-5181]: remove this block and re-test once we move `make test` to `mise run test`. - eval "$(mise env --cd "$repoDir" --shell bash)" - fi for godir in $(go_mod_dirs); do run_go_tests "$godir" "$@" || fatal "Tests failed in $godir" done