fix: KEEP-1056 pin cobra/doc tooling deps so go mod tidy stops pruning go.sum - #82
Merged
Merged
Conversation
…g go.sum generate.go carries //go:build ignore, so go mod tidy never sees its import of github.com/spf13/cobra/doc and prunes go-md2man and blackfriday from go.sum. Doc generation then fails with a missing go.sum entry. Dependabot runs tidy on every bump, so this broke docs-check on PRs #36, #37 and #81. Add a tools-tagged blank import. go mod tidy evaluates imports under all build tag combinations, unlike the compiler, so the tag keeps the file out of every real build while holding those hashes pinned. Verified: tidy now leaves go.sum untouched, and go list -deps ./cmd/kh has no md2man. Also promote golang.org/x/crypto out of the indirect block: cmd/read/read.go imports it directly, so go.mod was not tidy-clean and any tidy run moved it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every dependabot Go module bump fails the
docs-checkCI job:docs/generate.gocarries//go:build ignore, sogo mod tidynever sees its import ofgithub.com/spf13/cobra/doc. Tidy treatsgo-md2man/v2andblackfriday/v2as unreachableand prunes their
h1:hashes from go.sum. Doc generation then cannot compilecobra/doc.Dependabot runs tidy on every bump, so this reproduces on every Go module PR.
KEEP-1051 (#76) moved the
//go:generatedirective intodocs/doc.gobecause directives inbuild-excluded files are never scanned. That made generation actually run, which exposed this
latent hole rather than creating it.
Fix
A
tools-tagged blank import indocs/tools.go.go mod tidyevaluates imports under allbuild tag combinations, unlike the compiler, so the tag keeps the file out of every real build
while holding the hashes pinned.
Alternatives considered and rejected:
tooldirective:cobra/docis a library, not a main package, sogo toolrejectsit, and
go get -toolsilently upgraded cobra to 1.10.2 as a side effect.go getbefore generating:docs-checkonly runsgit diff --exit-code docs/, soit would go green while leaving main's go.sum pruned, breaking
go generatelocally foreveryone and at release time in
sync-cli-docs.yml.Also included
golang.org/x/cryptowas marked// indirectwhilecmd/read/read.go:13imports it directly,so go.mod was not tidy-clean and any tidy run promoted it. Landing that deliberately here.
Version is unchanged at 0.46.0; the bump to 0.52.0 remains #81's job.
Verification
Run in
golang:1.25andgolangci-lint:latest-alpinecontainers:go mod tidynow leaves go.sum completely untouched (previously it stripped fourh1:lines)go generate ./docs/succeeds andgit diff --exit-code docs/is clean, which is the check that fails on chore(deps): bump golang.org/x/crypto from 0.46.0 to 0.52.0 #81 todaygo build ./...,go vet ./...,go test ./...(28 packages) all passgolangci-lint run ./...reports 0 issuesgo list -deps ./cmd/khcontains no md2man, so the shipped binary is unaffectedFollow-up
PRs #36, #37 and #81 all carry the identical pruning and will keep failing
docs-checkuntilthis lands. Once merged,
@dependabot recreateeach so tidy reruns against a main containingtools.go. #32 (actions/checkout) is unaffected.