Share the locked invocation lifecycle
This commit is contained in:
@@ -140,7 +140,7 @@ can call it without rebuilding requests or acquiring a second lock.
|
|||||||
|
|
||||||
## Stage 3: Extract The Runner's Locked Invocation Lifecycle
|
## Stage 3: Extract The Runner's Locked Invocation Lifecycle
|
||||||
|
|
||||||
Status: Pending.
|
Status: Complete. Verified with `GOTOOLCHAIN=go1.27.4 go test ./internal/app` and `git diff --check`.
|
||||||
|
|
||||||
Read `internal/app/{runner,runner_runtime,runner_stage_execution,runner_finalization,runner_composition,runner_dependencies}.go`,
|
Read `internal/app/{runner,runner_runtime,runner_stage_execution,runner_finalization,runner_composition,runner_dependencies}.go`,
|
||||||
[Workspace Internals](../internal/workspace.md), and runner cancellation,
|
[Workspace Internals](../internal/workspace.md), and runner cancellation,
|
||||||
|
|||||||
@@ -45,7 +45,11 @@ func executePlan(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts
|
|||||||
return executePlanWithDependencies(ctx, cfg, plan, opts, invocationDependencies{})
|
return executePlanWithDependencies(ctx, cfg, plan, opts, invocationDependencies{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts RunOptions, dependencies invocationDependencies) (summary *RunSummary, resultErr error) {
|
func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts RunOptions, dependencies invocationDependencies) (*RunSummary, error) {
|
||||||
|
return withLockedInvocation(ctx, cfg, plan, opts, dependencies, executeSelectedStages)
|
||||||
|
}
|
||||||
|
|
||||||
|
func withLockedInvocation(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts RunOptions, dependencies invocationDependencies, operation func(*invocationRuntime) error) (summary *RunSummary, resultErr error) {
|
||||||
dependencies = dependencies.normalized()
|
dependencies = dependencies.normalized()
|
||||||
runtime, err := prepareInvocation(ctx, cfg, plan, opts, dependencies)
|
runtime, err := prepareInvocation(ctx, cfg, plan, opts, dependencies)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -92,16 +96,20 @@ func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan B
|
|||||||
}
|
}
|
||||||
|
|
||||||
runtime.env.Info("selected run destinations", "session", runtime.identity.SessionID, "run", runtime.identity.RunID, "manifest", runtime.manifestPath, "workspace", runtime.identity.LocalWorkDir)
|
runtime.env.Info("selected run destinations", "session", runtime.identity.SessionID, "run", runtime.identity.RunID, "manifest", runtime.manifestPath, "workspace", runtime.identity.LocalWorkDir)
|
||||||
|
return nil, operation(runtime)
|
||||||
|
}
|
||||||
|
|
||||||
|
func executeSelectedStages(runtime *invocationRuntime) error {
|
||||||
downstreamChecked := false
|
downstreamChecked := false
|
||||||
for index, selected := range runtime.stages {
|
for index, selected := range runtime.stages {
|
||||||
if selected.Name() != "prepare" && !downstreamChecked {
|
if selected.Name() != "prepare" && !downstreamChecked {
|
||||||
downstreamChecked = true
|
downstreamChecked = true
|
||||||
if err := inspectInvocationRequirements(runtime, index); err != nil {
|
if err := inspectInvocationRequirements(runtime, index); err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := runtime.ctx.Err(); err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
outcome, err := executeSelectedStage(runtime, selected)
|
outcome, err := executeSelectedStage(runtime, selected)
|
||||||
result := &runtime.stageResults[index]
|
result := &runtime.stageResults[index]
|
||||||
@@ -129,10 +137,10 @@ func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan B
|
|||||||
runtime.skipped = append(runtime.skipped, selected.Name())
|
runtime.skipped = append(runtime.skipped, selected.Name())
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, ctx.Err()
|
return runtime.ctx.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func stagesContainAny(stages []stage.Stage, names ...string) bool {
|
func stagesContainAny(stages []stage.Stage, names ...string) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user