Skip to content

Add Go module collection support#14

Draft
dagger-codex[bot] wants to merge 2 commits into
mainfrom
codex/go-collections
Draft

Add Go module collection support#14
dagger-codex[bot] wants to merge 2 commits into
mainfrom
codex/go-collections

Conversation

@dagger-codex

@dagger-codex dagger-codex Bot commented Jun 1, 2026

Copy link
Copy Markdown

Summary

Go workspaces get three selection dimensions — go-module, go-directory, go-test — with batched test execution:

$ dagger list go-test --go-directory=app/sub
TestSubDouble
TestSubZero

$ dagger check --go-test=TestSubDouble --go-test=TestSubZero
ok  example.com/app/sub  0.001s        # one go test -run '^(TestSubDouble|TestSubZero)$'

GoModule.testDirs exposes 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-level run is a batch check that shadows the per-test run: selecting several tests compiles and runs them in a single go test invocation, and dimension filters push down so only selected directories enumerate.

Go.modules() returns a GoModules collection (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.

$ dagger list go-module
./app
./lib

$ dagger call modules subset --keys ./app keys
./app

Authored with Dang's @keys/@get directives; 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-check passes, including new assertions: get(key:) returns the requested module, subset(keys:) narrows exactly.
  • Consumer workspace UX: dagger list go-module, dagger call modules keys / subset --keys ... keys work against this module.

Notes

  • 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.
  • The check-selection flow (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.mod across the whole workspace; when the module source directory lives inside the workspace, its own embedded go.mods appear too. Pre-existing behavior, unchanged here.

@dagger-codex dagger-codex Bot force-pushed the codex/go-collections branch from d24d89a to 50ad694 Compare June 1, 2026 21:54
@dagger-codex dagger-codex Bot changed the title Add collection support to the Go module Add Go module collection support Jun 1, 2026
Signed-off-by: Solomon Hykes <solomon@dagger.io>
@shykes shykes force-pushed the codex/go-collections branch from 50ad694 to ab183bb Compare June 10, 2026 08:36
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>
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