Select and check downstream preflight targets

This commit is contained in:
2026-11-27 16:41:09 +00:00
parent 2db2554d1e
commit b9b154e59e
5 changed files with 165 additions and 1 deletions

View File

@@ -79,3 +79,28 @@ func buildInspectionTargets(cfg *config.Config, sessionID string, trim bool, key
}
return targets, nil
}
// executionDownstreamTargets selects checks only for projected work.
func executionDownstreamTargets(cfg *config.Config, sessionID string, projection *workProjection) (preflight.Targets, error) {
targets, err := executionInspectionTargets(cfg, sessionID, projection)
if err != nil {
return preflight.Targets{}, err
}
result := preflight.Targets{Scriptorium: targets}
for _, item := range projection.Stages {
if item.Name == "polish" && item.Decision.action == stageActionRun {
result.Polish = true
}
}
return result, nil
}
// validationDownstreamTargets selects checks for enabled functionality regardless of reuse.
func validationDownstreamTargets(cfg *config.Config, sessionID string) (preflight.Targets, error) {
targets, err := validationInspectionTargets(cfg, sessionID)
if err != nil {
return preflight.Targets{}, err
}
// Polish is a canonical pipeline stage and has no enable/disable setting.
return preflight.Targets{Polish: true, Scriptorium: targets}, nil
}

View File

@@ -127,3 +127,27 @@ func TestInspectionTargetsExpandSelectedFamilyAndIgnoreUnrelatedRange(t *testing
t.Fatalf("unrelated targets = %+v, error = %v", targets, err)
}
}
func TestDownstreamTargetSelectionForPolish(t *testing.T) {
cfg := &config.Config{Pipeline: &config.PipelineConfig{}}
for _, tc := range []struct {
name string
stages []projectedStage
want bool
}{
{"selected", []projectedStage{{Name: "polish", Decision: preExecutionDecision{action: stageActionRun}}}, true},
{"reused", []projectedStage{{Name: "polish", Decision: preExecutionDecision{action: stageActionSkip}}}, false},
{"unrelated", []projectedStage{{Name: "prepare", Decision: preExecutionDecision{action: stageActionRun}}}, false},
} {
t.Run(tc.name, func(t *testing.T) {
got, err := executionDownstreamTargets(cfg, "session", &workProjection{Stages: tc.stages})
if err != nil || got.Polish != tc.want || len(got.Scriptorium) != 0 {
t.Fatalf("targets: %+v %v", got, err)
}
})
}
got, err := validationDownstreamTargets(cfg, "session")
if err != nil || !got.Polish {
t.Fatalf("validation targets: %+v %v", got, err)
}
}