Skip to content

auto_version: skip non-publishable go.mod modules#202

Merged
yanyi-wego merged 1 commit into
mainfrom
chore/auto-version-skip-non-publishable-modules
May 4, 2026
Merged

auto_version: skip non-publishable go.mod modules#202
yanyi-wego merged 1 commit into
mainfrom
chore/auto-version-skip-non-publishable-modules

Conversation

@yanyi-wego
Copy link
Copy Markdown
Contributor

@yanyi-wego yanyi-wego commented Apr 27, 2026

Summary

  • auto_version now reads the module … line from each go.mod and only tags directories whose declared path equals github.com/wego/pkg/<relative-dir>. Anything else is skipped with a reason.
  • Fixes the recent erroneous tagging of linters/isolint/testdata/v0.1.0, linters/isolint/testdata/v0.1.1, and linters/stringlint/testdata/v0.1.0. Those directories are standalone Go modules only because golang.org/x/tools/go/analysis/analysistest requires fixtures to be a self-contained module, and they declare module example — they are not meant for consumption.
  • Cleanup of the already-pushed bad tags is not part of this PR. Doing it separately so the destructive git push :refs/tags/... is reviewed on its own.

Why module-path matching (and not the alternatives)

Option How it would work Why rejected
Path filter */testdata/* find … -not -path '*/testdata/*' Only covers the testdata convention. Misses any future auxiliary go.modexamples/, benchmarks/, cmd/playground/, etc. Hardcodes one naming convention into the release tooling.
Marker file (.no-release / .tagignore) Opt-out per directory New convention to teach. Easy to forget when adding another linter; the failure mode is silent (a stray release tag).
Allow-list in script Hardcode the publishable dirs Every new package edits the script. Forgetting it means the package never gets tagged — silent failure in the other direction.
Module-path check (chosen) Require go.mod's module … line to equal github.com/wego/pkg/<dir>; skip with a logged reason otherwise See below.

Why this is cleaner and scales

  • It tests the actual property we care about. The release tooling's job is to publish wego/pkg modules. The truthful question is "does this go.mod declare itself as part of github.com/wego/pkg?" Module path matching answers that directly; every other option is a proxy.
  • No new convention. It piggybacks on the module directive that go.mod files already have. Nothing new for contributors to remember.
  • Auto-handles every current and future case. Linter testdata today, more linter fixtures tomorrow, example modules, benchmark harnesses — all handled without script changes, because none of them will declare a github.com/wego/pkg/... module path.
  • Self-documenting failure mode. When something is skipped, the script logs skipping <pkg> (module path "X" is not "Y"). If a real package is misconfigured, the mismatch is loud and immediately diagnosable.
  • Works at any nesting depth. The check concatenates module_root + relative dir, so iso/site, http/middleware, linters/isolint, and any future a/b/c resolve identically — no special casing.

Verification

Dry-run against every go.mod in the repo classified all 33 publishable modules as TAG and both linter testdata fixtures as SKIP with the expected reason.

  • Separately (not in this PR) clean up the existing bad remote tags: linters/isolint/testdata/v0.1.0, linters/isolint/testdata/v0.1.1, linters/stringlint/testdata/v0.1.0.

🤖 Generated with Claude Code

The script tagged every directory containing a go.mod, which
incorrectly published linter testdata fixtures (e.g.
linters/isolint/testdata/v0.1.1) as releasable modules. Those
fixtures are required to be standalone modules by
analysistest, but they declare placeholder paths like
"module example" and are not meant for consumption.

Now each go.mod's declared module path must equal
github.com/wego/pkg/<relative-dir>; mismatches are skipped
with a reason. This is the truthful semantic test for "is
this a publishable wego/pkg module?", and it scales to any
future auxiliary go.mod (more linter fixtures, examples,
benchmarks) without needing path filters or marker files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yanyi-wego yanyi-wego merged commit e1239cc into main May 4, 2026
2 checks passed
@yanyi-wego yanyi-wego deleted the chore/auto-version-skip-non-publishable-modules branch May 4, 2026 04:37
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.

4 participants