Skip to content

fix: Tidy Go modules under examples and tests - #49

Merged
privateip merged 2 commits into
mainfrom
fix/renovate-tidy-nested-go-modules
Dec 1, 2026
Merged

privateip merged 2 commits into
mainfrom
fix/renovate-tidy-nested-go-modules

Conversation

@privateip

@privateip privateip commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Strict config validation passes
  • A Renovate dry run on galactic's main branch reads both example modules, and their k8s.io patch bumps land in the same branch as the root's
  • A root-only update on galactic tidies both examples, and go mod tidy in each then leaves no diff
  • The next Renovate run on galactic updates and tidies the example modules alongside the root

Related to datum-cloud/galactic#1554

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
@privateip privateip self-assigned this Dec 1, 2026
@privateip privateip changed the title fix: Tidy Go modules under examples and test directories fix: Tidy Go modules under examples and tests Dec 1, 2026
@privateip
privateip marked this pull request as ready for review December 1, 2026 22:29
@privateip
privateip requested a review from a team as a code owner December 1, 2026 22:29
@privateip
privateip requested a review from ecv December 1, 2026 22:31

@scotwells scotwells left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@privateip

Copy link
Copy Markdown
Contributor Author

Addressed in eb7904d. The tidy rule now uses gomodTidyAll instead of gomodTidy. After tidying the go.mod it updated, Renovate finds every go.mod whose local replace points at that module, runs go mod tidy in each, and commits their go.mod and go.sum in the same branch. The option needs Renovate 44.28.0 or later; the current release is 45.11.1.

I tested a root-only update by running Renovate 45.11.1's gomod artifact step on galactic at 2d5d35b8, with golang.org/x/net moved from v0.62.0 to v0.63.0 in the root go.mod only. looking-glass-client lists it as indirect, which Renovate skips.

Tidy option Files Renovate commits go mod tidy in each example afterwards
gomodTidy root go.mod and go.sum changes go.mod and go.sum in both examples
gomodTidyAll root plus both examples' go.mod and go.sum no diff; both examples build and pass go vet

A root-only update outside the examples' module graph (quic-go v0.64.1 to v0.66.0) leaves the examples untouched under gomodTidyAll.

@privateip
privateip requested a review from scotwells December 1, 2026 22:48

@scotwells scotwells left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root-only update now tidies both dependent examples, and the control case leaves unaffected examples unchanged. That resolves my earlier concern.

@privateip
privateip merged commit 2e22b69 into main Dec 1, 2026
4 checks passed
@privateip
privateip deleted the fix/renovate-tidy-nested-go-modules branch December 1, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants