Skip to content

Detect a Go module kept in src/ or one level down - #45

Merged
imanimanyara merged 1 commit into
mainfrom
fix/detect-nested-go-module
Nov 8, 2026
Merged

imanimanyara merged 1 commit into
mainfrom
fix/detect-nested-go-module

Conversation

@imanimanyara

Copy link
Copy Markdown
Member

Summary

probaci looked for go.mod only at the repository root. After #42 moved probaci's own module into src/, its self-test reported languages=[], and every stage still passed. Any repository using the src/ layout would show the same result.

  • Detection (internal/detect): uses a root go.mod first, then src/go.mod, then the first other immediate subdirectory that has one, in name order. It never looks more than one level down. vendor/, testdata/, node_modules/ and directories starting with . or _ are skipped.
  • Commands run in the module. Language.Dir records the module directory. For a nested module, install and test become go -C <dir> mod download and go -C <dir> test ./.... A bare go test ./... at the root finds no packages and passes.
  • Containers start in the module. RunSpec.WorkDir sets -w /workspace/<dir>, and the per-language lint and audit stages pass l.Dir. Without this, golangci-lint and govulncheck would run at the root and report clean on nothing. Every other tool still starts at /workspace.
  • CI guard: the selftest job now asserts that the detect stage reports languages=[go].

Evidence

  • New tests fail on main. With only the new fields added and no detection change, 5 tests fail on behaviour: InSrc, OneLevelDown, PrefersRootThenSrc, Self and BuildArgsWorkDir. All pass with the fix.
  • TestDetectSelf runs detection on probaci's own repository root and requires Go in src/.
  • The new tests cover false positives: a go.mod under vendor, testdata, node_modules, .cache or _parked is not detected. A go.mod two levels down is not detected either.
  • Self-test before and after:
    • main build: vcs=git languages=[] platforms=[github(lint+run)]
    • this branch: vcs=git languages=[go] platforms=[github(lint+run)]
  • The CI guard step was run locally against both builds. It passes on this branch and fails on main's binary.
  • Local checks: go vet ./..., go test ./..., golangci-lint run (0 issues) and gofmt -l (clean).

Language detection only looked for go.mod at the repository root, so
probaci's own self-test, and any repository using the src/ module layout,
reported languages=[] while every stage still passed.

Detection now takes a root go.mod first, then src/go.mod, then the first
other immediate subdirectory with one, skipping vendor/, testdata/,
node_modules/ and "." or "_" prefixed directories. The language records
its module directory: install and test commands become go -C <dir>, and
lint and audit containers start in /workspace/<dir>, so golangci-lint and
govulncheck find packages instead of passing on an empty root.

The CI self-test now asserts the detect stage reports languages=[go].
Copilot AI balanced review requested due to automatic review settings November 8, 2026 05:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@imanimanyara
imanimanyara merged commit 2f8ef43 into main Nov 8, 2026
10 checks passed
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