Skip to content

chore: clean up the module surface and broaden e2e coverage - #14

Merged
TomChv merged 1 commit into
mainfrom
chore/cleanup-and-expand-e2e-coverage
Jul 30, 2026
Merged

TomChv merged 1 commit into
mainfrom
chore/cleanup-and-expand-e2e-coverage

Conversation

@TomChv

@TomChv TomChv commented Jul 29, 2026

Copy link
Copy Markdown
Member

Cleanup pass over the SDK module plus a wider e2e suite: 20 checks → 29, all green.

Cleanup

Drop pub. dang defaults field forms with a disambiguating token (: type, (args), { block }) to public, so the keyword is noise. Matches what go-sdk already did.

Split the e2e module by SDK surface. main.dang went from 631 lines to one check group per file — sdk, lookup, discovery, init, config, generate, client — sharing the assertions and fixture paths in util.dang. Check names become e-2-e:<group>:<check>, so dagger check "e-2-e:config:*" runs a group on its own.

Fixes

Three of these were found by writing the new checks.

ModConfig read the wrong directory. It resolved package.json / deno.json against the directory holding the module config, but the TypeScript runtime reads them from the module's source subpath. A module config carrying source = "../.." — the layout workspace migration writes, config in .dagger/modules/<name>/ pointing back at pre-existing code — made config package-manager report an unconfigured module, and config set write a stray package.json next to dagger-module.toml where the engine never looks. Mod.sourcePath now resolves through the engine.

generateAllClient ignored the caller's location. It regenerated every workspace client unconditionally. Nested under the engine's per-dependency generation the cwd is the dependency, so staging a client from elsewhere in the workspace failed outright:

generate local dependency ".../generate-deps/dep": workspace path .../client/out
is outside changeset root .../generate-deps/dep

That fires as soon as a managed module has a managed local dependency. It is now cwd-scoped like generateAllModule.

--template "" produced a broken module. The empty name resolved to the templates/ directory itself, which exists — so it passed the unknown-template guard and rendered every starter as a subdirectory of the new module. It now means the default, which is what the docstring already claimed.

generateAllModule generated sequentially. Now folds with map + withChangesets so managed modules generate concurrently.

Coverage

New fixture parent-source/ reproduces the migrated layout (config in .dagger/modules/app, code in ci/, source = "../../../ci"), covered across discovery and config. generate-deps/{app,dep} are now both workspace-managed, so generation is checked one module at a time and all at once — the dependent's changeset carries its dependency's bindings without leaking the dependency's own files, and the two changesets merge cleanly.

Also added: generate-all scoping, init rejections (path escape, unknown template, --package-manager on a runtime that bundles its own), initClient, template listing, contradictory Deno/Node layouts, and lookups that must fail.

Docs

Each initModule / initClient / generateClient / mod argument is now documented, so dagger sdk module-options typescript describes its flags instead of printing a column of dashes:

FLAG               TYPE                  REQUIRED  DESCRIPTION
--template         string                no        Starter to materialize from templates/<template>: …
--runtime          TypescriptSdkRuntime  no        TypeScript runtime the module runs on. …
--package-manager  string                no        packageManager pin for package.json, as `name@version` …
--base-image       string                no        Base container image the module builds on. …

README corrections: the polyfill link (dagger/polyfill, not sdk-sdk/polyfill); dagger sdk install typescript, since the ref form registers the SDK as typescript-sdk, not typescript; the helper module name (dagger-typescript-sdk); generate-all → generate-all-module / generate-all-client; and the stale note claiming discovery scans legacy dagger.json files. Adds client generation, cwd scoping, relocated sources, and a Development section.

Known gaps

  • Generating a relocated-source module returns an empty changeset. The pinned polyfill scopes the generated context to --root <config dir>, so output landing in ci/ is dropped. Already fixed on an unpushed polyfill branch (switching to core.generatedContextChangeset); origin/main is still our pin, so the parent-source checks deliberately cover discovery and config only. The check docstring says why.
  • Standing in a module's source directory finds nothing — discovery anchors on config directories, so dagger generate from ci/ is a no-op. Same in go-sdk and python-sdk; the fix belongs in the shared convention. Pinned by a test so a change is deliberate.
  • helperTestsCheck still skips helpers/module-config (which has tests that never run) and helpers/render-template (which has none).

Test

dagger check — 29 passed. dagger generate --no-apply verified end to end against the expanded fixture set.

Drop the `pub` keyword now that dang defaults field forms carrying a
disambiguating token (`:` type, `(args)`, `{ block }`) to public, matching
what go-sdk already did.

Split the e2e module by SDK surface: main.dang exposes one check group per
file (sdk, lookup, discovery, init, config, generate, client), sharing the
assertions and fixture paths in util.dang. Check names become
`e-2-e:<group>:<check>`, so a group can be run on its own.

Fixes found while writing the new checks:

- ModConfig resolved package.json/deno.json against the directory holding
  the module config, but the TypeScript runtime reads them from the module
  source subpath. A module config carrying `source = "../.."` — the layout
  workspace migration writes — made config reads report an unconfigured
  module and config edits write a stray package.json the engine never looks
  at. Mod.sourcePath now resolves through the engine.

- generateAllClient regenerated every workspace client regardless of the
  caller's location. Nested under the engine's per-dependency generation the
  cwd is the dependency, so staging a client from elsewhere in the workspace
  failed outright ("outside changeset root") as soon as a managed module had
  a managed dependency. It is now cwd-scoped like generateAllModule.

- An unnamed init template resolved to the templates/ directory itself,
  which exists, so it passed the unknown-template guard and rendered every
  starter as a subdirectory of the new module. It now means the default,
  as the docstring already claimed.

generateAllModule folds each module's changes with map + withChangesets
instead of a sequential reduce, so managed modules generate concurrently.

New coverage: a relocated module source (config in .dagger/modules/app,
code in ci/) across discovery and config; a managed module and its managed
local dependency, generated one at a time and all at once; generate-all
scoping; init rejections; initClient; template listing; contradictory
Deno/Node layouts; and lookups that must fail.

Docs: document each initModule/initClient/generateClient/mod argument, so
`dagger sdk module-options typescript` describes its flags instead of
printing a column of dashes. README corrects the polyfill link, the install
form that actually registers the SDK as `typescript`, the helper module
name, the generate-all function names, and the stale claim that discovery
scans legacy dagger.json files; it also covers client generation, cwd
scoping and relocated sources.

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv
TomChv requested a review from tiborvass July 30, 2026 14:01
@TomChv
TomChv merged commit 9c24544 into main Jul 30, 2026
30 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