(currentRun ProcessedRun, processedRuns []ProcessedRun)
| 302 | } |
| 303 | |
| 304 | func buildAuditComparisonForProcessedRuns(currentRun ProcessedRun, processedRuns []ProcessedRun) *AuditComparisonData { |
| 305 | auditComparisonLog.Printf("Building audit comparison for run %d from %d processed runs", currentRun.Run.DatabaseID, len(processedRuns)) |
| 306 | currentSnapshot := buildAuditComparisonSnapshot(currentRun, extractCreatedItemsFromManifest(currentRun.Run.LogsPath)) |
| 307 | candidates := make([]auditComparisonCandidate, 0, len(processedRuns)) |
| 308 | |
| 309 | for _, candidateRun := range processedRuns { |
| 310 | if candidateRun.Run.DatabaseID == currentRun.Run.DatabaseID { |
| 311 | continue |
| 312 | } |
| 313 | if candidateRun.Run.Conclusion != "success" { |
| 314 | continue |
| 315 | } |
| 316 | if !candidateRun.Run.CreatedAt.Before(currentRun.Run.CreatedAt) { |
| 317 | continue |
| 318 | } |
| 319 | if !sameAuditComparisonWorkflow(currentRun.Run, candidateRun.Run) { |
| 320 | continue |
| 321 | } |
| 322 | |
| 323 | candidates = append(candidates, buildAuditComparisonCandidateFromProcessedRun(candidateRun)) |
| 324 | } |
| 325 | |
| 326 | selected := selectAuditComparisonBaseline(currentRun, candidates) |
| 327 | if selected == nil { |
| 328 | return &AuditComparisonData{BaselineFound: false} |
| 329 | } |
| 330 | |
| 331 | comparison := buildAuditComparison(currentSnapshot, &selected.Run, &selected.Snapshot) |
| 332 | if comparison != nil && comparison.Baseline != nil { |
| 333 | comparison.Baseline.Selection = selected.Selection |
| 334 | comparison.Baseline.MatchedOn = selected.MatchedOn |
| 335 | } |
| 336 | return comparison |
| 337 | } |
| 338 | |
| 339 | func buildAuditComparison(current auditComparisonSnapshot, baselineRun *WorkflowRun, baseline *auditComparisonSnapshot) *AuditComparisonData { |
| 340 | if baselineRun == nil || baseline == nil { |
no test coverage detected