Repository navigation
Detect a Go module kept in src/ or one level down - #45
Merged
Merged
Conversation
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].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
probaci looked for
go.modonly at the repository root. After #42 moved probaci's own module intosrc/, its self-test reportedlanguages=[], and every stage still passed. Any repository using thesrc/layout would show the same result.internal/detect): uses a rootgo.modfirst, thensrc/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.Language.Dirrecords the module directory. For a nested module, install and test becomego -C <dir> mod downloadandgo -C <dir> test ./.... A barego test ./...at the root finds no packages and passes.RunSpec.WorkDirsets-w /workspace/<dir>, and the per-language lint and audit stages passl.Dir. Without this,golangci-lintandgovulncheckwould run at the root and report clean on nothing. Every other tool still starts at/workspace.selftestjob now asserts that the detect stage reportslanguages=[go].Evidence
main. With only the new fields added and no detection change, 5 tests fail on behaviour:InSrc,OneLevelDown,PrefersRootThenSrc,SelfandBuildArgsWorkDir. All pass with the fix.TestDetectSelfruns detection on probaci's own repository root and requires Go insrc/.go.modundervendor,testdata,node_modules,.cacheor_parkedis not detected. Ago.modtwo levels down is not detected either.mainbuild:vcs=git languages=[] platforms=[github(lint+run)]vcs=git languages=[go] platforms=[github(lint+run)]main's binary.go vet ./...,go test ./...,golangci-lint run(0 issues) andgofmt -l(clean).