Build artifact inventories only for pipeline run reports
Some checks failed
ci/woodpecker/push/verify Pipeline was canceled
Some checks failed
ci/woodpecker/push/verify Pipeline was canceled
This commit is contained in:
@@ -46,10 +46,14 @@ func executePlan(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts
|
||||
}
|
||||
|
||||
func executePlanWithDependencies(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts RunOptions, dependencies invocationDependencies) (*RunSummary, error) {
|
||||
return withLockedInvocation(ctx, cfg, plan, opts, dependencies, executeSelectedStages)
|
||||
result, err := withLockedInvocation(ctx, cfg, plan, opts, dependencies, executeSelectedStages)
|
||||
if result == nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.runSummary(err == nil), err
|
||||
}
|
||||
|
||||
func withLockedInvocation(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts RunOptions, dependencies invocationDependencies, operation func(*invocationRuntime) error) (summary *RunSummary, resultErr error) {
|
||||
func withLockedInvocation(ctx context.Context, cfg *config.Config, plan BoundedPlan, opts RunOptions, dependencies invocationDependencies, operation func(*invocationRuntime) error) (result *invocationResult, resultErr error) {
|
||||
dependencies = dependencies.normalized()
|
||||
runtime, err := prepareInvocation(ctx, cfg, plan, opts, dependencies)
|
||||
if err != nil {
|
||||
@@ -76,13 +80,10 @@ func withLockedInvocation(ctx context.Context, cfg *config.Config, plan BoundedP
|
||||
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)
|
||||
result, resultErr = finalizeInvocation(runtime, resultErr)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -28,7 +28,14 @@ type RunArtifact struct {
|
||||
Evidence string `json:"evidence"`
|
||||
}
|
||||
|
||||
func finalizeInvocation(runtime *invocationRuntime, operationErr error) (*RunSummary, error) {
|
||||
// invocationResult retains terminal evidence without projecting a report-specific
|
||||
// artifact inventory. Preflight needs only whether the lifecycle started.
|
||||
type invocationResult struct {
|
||||
runtime *invocationRuntime
|
||||
evidence *manifest.Manifest
|
||||
}
|
||||
|
||||
func finalizeInvocation(runtime *invocationRuntime, operationErr error) (*invocationResult, error) {
|
||||
evidence := runtime.manifest
|
||||
resultErr := operationErr
|
||||
if operationErr != nil {
|
||||
@@ -42,13 +49,18 @@ func finalizeInvocation(runtime *invocationRuntime, operationErr error) (*RunSum
|
||||
evidence = nil
|
||||
}
|
||||
}
|
||||
return &invocationResult{runtime: runtime, evidence: evidence}, resultErr
|
||||
}
|
||||
|
||||
func (result *invocationResult) runSummary(complete bool) *RunSummary {
|
||||
runtime := result.runtime
|
||||
return &RunSummary{
|
||||
SessionID: runtime.identity.SessionID, RunID: runtime.identity.RunID,
|
||||
ManifestPath: runtime.manifestPath, StageNames: runtime.stageNames,
|
||||
Executed: runtime.executed, Skipped: runtime.skipped,
|
||||
StageResults: runtime.stageResults, AvailableArtifacts: durableRunArtifacts(evidence),
|
||||
Complete: resultErr == nil,
|
||||
}, resultErr
|
||||
StageResults: runtime.stageResults, AvailableArtifacts: durableRunArtifacts(result.evidence),
|
||||
Complete: complete,
|
||||
}
|
||||
}
|
||||
|
||||
func durableRunArtifacts(m *manifest.Manifest) []RunArtifact {
|
||||
|
||||
@@ -76,11 +76,11 @@ func inspectConfiguredSessionReadiness(ctx context.Context, cfg *config.Config,
|
||||
newObjectStore: func(ctx context.Context, cfg *config.Config) (storage.ObjectStore, error) {
|
||||
return initializeObjectStoreBackend(ctx, cfg, deps.newObjectStore)
|
||||
}}
|
||||
summary, err := withLockedInvocation(ctx, cfg, plan, RunOptions{Reporter: deps.reporter}, invocationDeps, func(runtime *invocationRuntime) error {
|
||||
result, err := withLockedInvocation(ctx, cfg, plan, RunOptions{Reporter: deps.reporter}, invocationDeps, func(runtime *invocationRuntime) error {
|
||||
report.RunID = runtime.identity.RunID
|
||||
return assessSessionReadiness(runtime, report, deps)
|
||||
})
|
||||
if summary == nil && err != nil {
|
||||
if result == nil && err != nil {
|
||||
report.Findings = append(report.Findings, errorFinding("workspace", err.Error()))
|
||||
report.Checks = append(report.Checks, readinessCheck{Group: "workspace/storage", Outcome: "failed", Message: err.Error()})
|
||||
} else if err != nil {
|
||||
|
||||
@@ -165,9 +165,9 @@ func TestPreflightReportsPreparationPersistenceAndFinalizationFailures(t *testin
|
||||
}
|
||||
report := &sessionReadinessReport{Preparation: preparationAssessment{Outcome: "not_attempted"}}
|
||||
invDeps := invocationDependencies{newAudita: deps.newAudita, newScriptorium: deps.newScriptorium, newNotarius: deps.newNotarius}
|
||||
summary, err := withLockedInvocation(context.Background(), cfg, plan, RunOptions{Env: &Env{ManifestStore: mstore, ArtifactStore: local}}, invDeps, func(runtime *invocationRuntime) error { return assessSessionReadiness(runtime, report, deps) })
|
||||
if summary == nil || summary.Complete || !errors.Is(err, releaseFailure) {
|
||||
t.Fatalf("summary=%+v report=%+v error=%v", summary, report, err)
|
||||
result, err := withLockedInvocation(context.Background(), cfg, plan, RunOptions{Env: &Env{ManifestStore: mstore, ArtifactStore: local}}, invDeps, func(runtime *invocationRuntime) error { return assessSessionReadiness(runtime, report, deps) })
|
||||
if result == nil || !errors.Is(err, releaseFailure) {
|
||||
t.Fatalf("result=%+v report=%+v error=%v", result, report, err)
|
||||
}
|
||||
if failureAt == "preparation" {
|
||||
if report.Preparation.Outcome != "failed" || len(provider.PreflightRequests) != 0 {
|
||||
@@ -204,11 +204,11 @@ func TestPreflightCannotSucceedWithoutPreparedEvidence(t *testing.T) {
|
||||
deps := normalizeCommandDependencies(fakeCommandDependencies(&storage.FakeBackend{}, nil))
|
||||
report := &sessionReadinessReport{Preparation: preparationAssessment{Outcome: "not_attempted"}}
|
||||
plan := BoundedPlan{stages: []stage.Stage{resultStage{name: "prepare", result: &stage.StageResult{Disposition: stage.StageDispositionSkipped, SkipReason: "no inputs"}}}}
|
||||
summary, err := withLockedInvocation(context.Background(), cfg, plan, RunOptions{}, invocationDependencies{newAudita: deps.newAudita, newScriptorium: deps.newScriptorium}, func(runtime *invocationRuntime) error {
|
||||
result, err := withLockedInvocation(context.Background(), cfg, plan, RunOptions{}, invocationDependencies{newAudita: deps.newAudita, newScriptorium: deps.newScriptorium}, func(runtime *invocationRuntime) error {
|
||||
return assessSessionReadiness(runtime, report, deps)
|
||||
})
|
||||
if err == nil || summary == nil || summary.Complete || report.Preparation.Outcome != "failed" {
|
||||
t.Fatalf("summary=%+v report=%+v error=%v", summary, report, err)
|
||||
if err == nil || result == nil || report.Preparation.Outcome != "failed" {
|
||||
t.Fatalf("result=%+v report=%+v error=%v", result, report, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user