Skip to content

go: start test sessions only when needed - #83

Merged
tiborvass merged 1 commit into
mainfrom
codex/pr81-import-safe-codegen
Nov 2, 2026
Merged

tiborvass merged 1 commit into
mainfrom
codex/pr81-import-safe-codegen

Conversation

@tiborvass

@tiborvass tiborvass commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Draft: waiting for the engine fix in dagger/dagger#14880 and a CI
upgrade to an engine version that includes it.

The test runner opens a Dagger session for every test command. Generated
bindings require this at package load time, even when the tests never
call Dagger. The same wrapper also starts sessions for tests that do not
import those bindings.

Generate the gobuild bindings with the engine fix in
dagger/dagger#14880. Run otelgotest directly. Keep
daggerInDaggerNewSession: true and the mounted CLI configuration.
Tests that use Dagger can then open a session against their own
workspace. The nesting test checks this behavior.

Depends on: dagger/dagger#14880

CI must upgrade to an engine version that includes dagger/dagger#14880
before this PR is ready for review.

The current CI generator restores the package-level session setup in
both generated files. This causes go-sdk/generate/stale to fail. After
the CI engine upgrade, regenerate the bindings and rerun the check.

Validation:

  • go test ./... in gobuild passed without session or engine settings.
  • The single-module and skips-non-modules checks passed.
  • The tests-collection and binary checks passed.
  • Scanner tests passed without session settings and with an invalid CLI
    path.

A local benchmark measured 3-7% shorter pure-Go test runs with warm
caches. Each workload used 12 pairs with alternating order and no
test-result cache. This measures the combined changes to codegen and the
test runner. It does not establish an improvement for the complete CI
run.

tiborvass added a commit to dagger/dagger that referenced this pull request Oct 27, 2026
Generated Go bindings read session settings at package load time. A test
that only imports these bindings fails before any test can run. This
forces the test runner to open a session for tests that never use
Dagger.

Read the settings on the first API request. Share one client between
normal queries and handles decoded from JSON. Return an error for
missing or invalid settings, and allow a later request to try again.
Keep the client after the first successful configuration check.

The regression test compiles both generated packages without a session.
It checks handles created before session setup, configuration errors,
concurrent requests, and authentication. The test fails with the
original package initialization panic on the previous templates.

Validation: GOFLAGS=-race go test ./cmd/codegen/generator/go/...

Companion change: dagger/go#83

Signed-off-by: Tibor Vass <[email protected]>
@tiborvass
tiborvass force-pushed the codex/pr81-import-safe-codegen branch from 44f95f9 to 1404477 Compare October 27, 2026 14:21
@tiborvass tiborvass changed the title fix: run Go tests without eagerly starting Dagger sessions go: start test sessions only when needed Oct 27, 2026
@tiborvass
tiborvass marked this pull request as draft October 27, 2026 14:42
@tiborvass
tiborvass marked this pull request as ready for review October 29, 2026 15:11
@grouville
grouville self-requested a review November 1, 2026 07:54
The test runner opens a Dagger session for every test command. Generated
bindings require this at package load time, even when the tests never
call Dagger. The same wrapper also starts sessions for tests that do not
import those bindings.

Generate the gobuild bindings with the deferred session setup from
dagger/dagger#14880. Run otelgotest without the session wrapper. Keep
access to the mounted CLI so tests can start a session when they need
one. Update the nesting test to open its own session and check workspace
access.

The engine used for generation must include dagger/dagger#14880. The
released engine still writes the previous initializers, so the
generated-file check fails until that dependency is available.

Validation: gobuild tests passed without session settings. The
single-module, skips-non-modules, tests-collection, and binary checks
passed. Scanner tests also passed without session settings and with an
invalid CLI path.

Depends on: dagger/dagger#14880

Signed-off-by: Tibor Vass <[email protected]>
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