Repository navigation
fix: Tidy Go modules under examples and tests - #49
Conversation
config:recommended ignores examples, test and tests directories, so
Renovate never updates or tidies a go.mod there. Such a module often
replaces the repository's root module with a relative path, so when an
update moves a requirement in the root go.mod, the nested go.mod goes
stale. go mod tidy then fails on it, and golangci-lint refuses to load
it ("running `go mod tidy` may solve the problem"). That is how
datum-cloud/galactic#1554 went red after a k8s.io patch group.
Key features/changes:
- Give the gomod manager its own ignorePaths that keeps only vendor,
node_modules and Go testdata fixtures out, so nested modules are
extracted
- Their updates join the same group branches as the root module's, and
the existing gomodTidy option tidies each go.mod the branch changes
- Other managers keep config:recommended's ignore list
scotwells
left a comment
There was a problem hiding this comment.
Please cover the case where Renovate updates only the root module. Discovering the nested example fixes the dry run where both modules have a direct update, but gomodTidy can still skip an example that depends on the root through a local replace. Please make sure that example is tidied too, and verify with a root-only update that running go mod tidy in the example leaves no diff.
go mod tidy ran only in the go.mod Renovate edited. An example that builds against the root through a local replace, and lists the updated dependency as indirect or not at all, was left stale by a root-only update, and go mod tidy and golangci-lint then failed on it. gomodTidyAll also tidies every go.mod whose local replace points at the updated module, and commits those go.mod and go.sum files in the same branch.
|
Addressed in eb7904d. The tidy rule now uses I tested a root-only update by running Renovate 45.11.1's gomod artifact step on galactic at
A root-only update outside the examples' module graph ( |
scotwells
left a comment
There was a problem hiding this comment.
The root-only update now tidies both dependent examples, and the control case leaves unaffected examples unchanged. That resolves my earlier concern.
Summary
Renovate tidies only the Go modules it edits, and the recommended preset skips examples, test and tests directories. A nested module that builds against the root through a relative replace then goes stale on every root update, which turned datum-cloud/galactic#1554 red at lint.
Go modules now ignore only vendored code, node_modules and Go testdata, and Renovate also tidies every module that replaces the updated one with a local path, so a root-only update tidies the examples too.
This reaches eight nested modules today, in datumctl, galactic, infra and network-services-operator, through each repository's existing Go groups.
Test plan
Related to datum-cloud/galactic#1554