Publish outputs to checked destinations and preserve failure evidence
This commit is contained in:
@@ -21,41 +21,22 @@ func finishProcess(inv commandkit.Invocation, input processInput, prepared *prep
|
||||
completed := time.Now().UTC()
|
||||
snapshot.RunID, snapshot.StartedAt, snapshot.CompletedAt = prepared.RunID, prepared.Started, &completed
|
||||
snapshot.TranscriptPath, snapshot.OutputPath = input.Transcript, input.Output.Value
|
||||
if primary == nil {
|
||||
primary = inv.Context.Err()
|
||||
}
|
||||
snapshot.Status = reporting.StatusCompleted
|
||||
if primary != nil {
|
||||
snapshot = failedProcessingSnapshot(snapshot, primary, inv.Context.Err())
|
||||
}
|
||||
reportPaths := prepared.Prepared.Output.ReportPaths()
|
||||
var reports diagnostics.ReportBundle
|
||||
var failed func([]diagnostics.FileFailure) diagnostics.ReportBundle
|
||||
var render diagnostics.ReportRenderer
|
||||
if len(reportPaths) > 0 {
|
||||
var err error
|
||||
reports, err = renderReportBundle(snapshot)
|
||||
if err != nil {
|
||||
if primary == nil {
|
||||
primary = err
|
||||
render = func(cause error, failures []diagnostics.FileFailure) (diagnostics.ReportBundle, error) {
|
||||
report := snapshot
|
||||
if cause != nil {
|
||||
report = failedProcessingSnapshot(report, cause, inv.Context.Err())
|
||||
}
|
||||
snapshot.Status = reporting.StatusFailed
|
||||
}
|
||||
failed = func(failures []diagnostics.FileFailure) diagnostics.ReportBundle {
|
||||
result, bundleErr := renderReportBundle(failedOutputSnapshot(snapshot, failures))
|
||||
if bundleErr != nil {
|
||||
return reports
|
||||
if len(failures) > 0 {
|
||||
report = failedOutputSnapshot(report, failures)
|
||||
}
|
||||
return result
|
||||
return renderReportBundle(report)
|
||||
}
|
||||
}
|
||||
if canceled := inv.Context.Err(); primary == nil && canceled != nil {
|
||||
primary = canceled
|
||||
snapshot = failedProcessingSnapshot(snapshot, canceled, canceled)
|
||||
if failed != nil {
|
||||
reports = failed(nil)
|
||||
}
|
||||
}
|
||||
result := prepared.Prepared.Output.Finish(primary, transcript, reports, failed)
|
||||
result := prepared.Prepared.Output.Finish(inv.Context, primary, transcript, render)
|
||||
if result != nil {
|
||||
return commandkit.Failure(result.Error()).WithCause(result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user