Add Go module collection support#14
Draft
dagger-codex[bot] wants to merge 2 commits into
Draft
Conversation
d24d89a to
50ad694
Compare
Signed-off-by: Solomon Hykes <solomon@dagger.io>
50ad694 to
ab183bb
Compare
Layer two more collections under GoModules, giving Go workspaces three selection dimensions: go-module, go-directory, and go-test. GoModule.testDirs exposes the existing test directory discovery as a collection keyed by workspace-relative path. Each GoDirectory exposes its tests as a collection keyed by test name, enumerated with go test -list; skipped directories produce an empty collection. Test execution is batched: the collection-level run executes one go test -run '^(A|B)$' over the current subset, and shadows the per-test run so that selecting several tests by name (dagger check --go-test=A --go-test=B) compiles and runs them in a single invocation. Filters push down, so only selected directories enumerate their tests. Note: test directory discovery (pre-existing go-includes behavior) does not surface test files at a module root; only subdirectories containing _test.go files become test directories. Signed-off-by: Solomon Hykes <solomon@dagger.io>
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
Go workspaces get three selection dimensions —
go-module,go-directory,go-test— with batched test execution:GoModule.testDirsexposes test directory discovery as a collection keyed by path; each directory exposes its tests as a collection keyed by name (go test -list). The collection-levelrunis a batch check that shadows the per-testrun: selecting several tests compiles and runs them in a singlego testinvocation, and dimension filters push down so only selected directories enumerate.Go.modules()returns aGoModulescollection (keyed by workspace-relative module root path) instead of a plain list, making Go modules first-class artifacts: enumerable, selectable, and filterable through the standard collection surface.Authored with Dang's
@keys/@getdirectives; the engine projects the public surface (keys,list,get(key),subset(keys)). Internal callers (lintAll,testAll,generateAll) iterate via the raw backing members, which stay visible in-module.Rebased on main: the original marker-file plumbing was dropped in favor of main's skip-path configuration, which the collection simply carries to
get.Verification
Requires an engine with collection support (dagger/dagger#13299) — CI cannot pass until a release ships it. Validated against a dev engine built from that PR:
e2e:module-introspection-checkpasses, including new assertions:get(key:)returns the requested module,subset(keys:)narrows exactly.dagger list go-module,dagger call modules keys/subset --keys ... keyswork against this module.Notes
go-includesbehavior) does not surface test files at a module root; only subdirectories containing_test.gofiles become test directories.dagger check --go-test=…) additionally requires the plans-lite layer in [1.0-beta] modules-v2: add artifacts and collections dagger#13299.modules()discovers**/go.modacross the whole workspace; when the module source directory lives inside the workspace, its own embedded go.mods appear too. Pre-existing behavior, unchanged here.