Preserve partial run results and terminal failure causes

This commit is contained in:
2026-11-20 05:47:41 +00:00
parent 85df36a770
commit a6c6f1e4ab
13 changed files with 451 additions and 108 deletions

View File

@@ -26,12 +26,15 @@ type RunOptions struct {
}
type RunSummary struct {
SessionID string
RunID string
ManifestPath string
StageNames []string
Executed []string
Skipped []string
SessionID string
RunID string
ManifestPath string
StageNames []string
Executed []string
Skipped []string
StageResults []RunStageResult
AvailableArtifacts []RunArtifact
Complete bool
}
type pipelineExecutor func(context.Context, *config.Config, BoundedPlan, RunOptions) (*RunSummary, error)
@@ -62,7 +65,20 @@ func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan B
resultErr = errors.Join(resultErr, fmt.Errorf("release session lock: %w", releaseErr))
}
}
if summary != nil {
summary.Complete = resultErr == nil
}
}()
defer func() {
if runtime.started {
summary, resultErr = finalizeInvocation(runtime, resultErr)
}
}()
for _, selected := range runtime.stages {
runtime.stageNames = append(runtime.stageNames, selected.Name())
runtime.stageResults = append(runtime.stageResults, RunStageResult{Name: selected.Name(), Outcome: "not_attempted"})
}
if err := initializeLockedInvocation(runtime); err != nil {
return nil, err
@@ -71,20 +87,32 @@ func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan B
return nil, err
}
for _, selected := range runtime.stages {
runtime.stageNames = append(runtime.stageNames, selected.Name())
for index, selected := range runtime.stages {
outcome, err := executeSelectedStage(runtime, selected)
if err != nil {
return nil, err
result := &runtime.stageResults[index]
result.Attempted = outcome.executed
result.Reason = outcome.reason
switch {
case err != nil:
result.Outcome = "failed"
case outcome.reused:
result.Outcome = "reused"
case outcome.skipped:
result.Outcome = "skipped"
default:
result.Outcome = "completed"
}
if outcome.executed {
runtime.executed = append(runtime.executed, selected.Name())
}
if outcome.skipped {
if outcome.skipped && err == nil {
runtime.skipped = append(runtime.skipped, selected.Name())
}
if err != nil {
return nil, err
}
}
return finalizeInvocation(runtime)
return nil, nil
}
func stagesContainAny(stages []stage.Stage, names ...string) bool {