Skip to content

Commit 41708ff

Browse files
committed
fix: prevent stale vendor/ from triggering inconsistent vendoring in CI
actions/checkout does not always remove previously-tracked files that were deleted in a later commit. A runner that checked out a commit with vendor/ and then checks out a commit without it may still find vendor/ on disk, causing Go to auto-activate vendor mode and fail with 'inconsistent vendoring'. Add GOFLAGS=-mod=mod at workflow level so all jobs explicitly use module mode regardless of whether a stale vendor/ directory exists on disk. Also fix an off-by-one in the compile_binary diagnostic: repo_root was computed 3 levels up from test/helpers/ (reaching the parent of the repo) instead of 2 levels up (the repo root itself), causing the vendor/modules.txt presence check to report a false negative.
1 parent 31df1b6 commit 41708ff

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ on:
66
- main
77
pull_request:
88

9+
# Prevent Go from auto-activating vendor mode when a stale vendor/ directory
10+
# exists in the workspace. Actions/checkout does not always remove previously
11+
# tracked files that were deleted in a later commit, so a checkout of a commit
12+
# that removed vendor/ may still find the directory on disk, causing
13+
# "inconsistent vendoring" build failures.
14+
env:
15+
GOFLAGS: "-mod=mod"
16+
917
jobs:
1018
gh-285:
1119
strategy:

test/helpers/ghostferry_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def compile_binary
148148
# Captures GOMOD / GOWORK / GOFLAGS to detect unexpected workspace or
149149
# vendor-mode activation, and checks for a repo-level vendor/modules.txt.
150150
go_env, _ = Open3.capture2e("go", "env", "GOMOD", "GOWORK", "GOFLAGS")
151-
repo_root = File.expand_path("../../..", __dir__)
151+
repo_root = File.expand_path("../..", __dir__)
152152
vendor_txt = File.join(repo_root, "vendor", "modules.txt")
153153
@logger.debug("[compile_binary] go env: #{go_env.strip}")
154154
@logger.debug("[compile_binary] repo_root: #{repo_root}")

0 commit comments

Comments
 (0)