Skip to content

fix(lint): run golangci-lint and go test once per Go module - #340

Merged
piwi3910 merged 8 commits into
mainfrom
fix/lint-nested-go-modules
Nov 9, 2026
Merged

piwi3910 merged 8 commits into
mainfrom
fix/lint-nested-go-modules

Conversation

@piwi3910

@piwi3910 piwi3910 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

What

The gate's Go lint and Go test runner now run once per Go module, from the module's directory, instead of one run from the repo root.

Why

A changed file in a nested module (its own go.mod, e.g. momo's bench/ with a replace to ../) made golangci-lint fail with "main module (...) does not contain package ...", so the gate reported the file NOT checked and blocked a correct commit. go test narrowed to a nested package failed the same way ("setup failed ... main module does not contain package").

How

  • internal/gomod: nearest go.mod grouping (stops at the repo root); a go.work at the root keeps one group.
  • lintGo runs one golangci-lint per module group with Dir = module dir and patterns relative to it; finding paths are mapped back to repo-root-relative so the wanted filter and gitx.Finding stay correct.
  • Config: the module's own golangci config is found by golangci-lint; a root config is passed with --config to a nested module that has none; otherwise the procoder baseline.
  • testrun.runGo groups the narrowed packages the same way and merges the per-module verdicts. lint --types has no Go path (tsc and pyright only), so nothing to change there.

Testing

Unit tests in internal/lint (grouping, patterns, path mapping, stub-binary runs asserting directory, args, config and go.work behaviour) and internal/testrun (real nested module fixture). Verified on CI only; red run on a throwaway branch is recorded in a comment.

@piwi3910
piwi3910 merged commit 1e267c9 into main Nov 9, 2026
6 checks passed
@piwi3910
piwi3910 deleted the fix/lint-nested-go-modules branch November 9, 2026 13:11
This was referenced Nov 9, 2026
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.

1 participant