| 1 | using CascadeIDE.Contracts; |
| 2 | |
| 3 | namespace CascadeIDE.Cockpit.ComputingUnits.IdeHealth; |
| 4 | |
| 5 | /// <summary> |
| 6 | /// CCU «build/tests сводка»: формирует пару сегментов из сигналов сборки/тестов и решения области (solution/project). |
| 7 | /// Логика форматирования остаётся в <see cref="IdeHealthFormattingUnit"/>; этот юнит только выбирает нужную ветку. |
| 8 | /// </summary> |
| 9 | [ComputingUnit] |
| 10 | public sealed class IdeHealthBuildTestsUnit : ICockpitComputeUnit |
| 11 | { |
| 12 | public static IdeHealthBuildTestsUnit Default { get; } = new(); |
| 13 | |
| 14 | private IdeHealthBuildTestsUnit() |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | public IdeHealthBuildTestsSnapshot Compose( |
| 19 | IdeHealthScopeDecision scopeDecision, |
| 20 | BuildStateSnapshot buildState, |
| 21 | string? testSummary, |
| 22 | int impactedTestsBadge) |
| 23 | { |
| 24 | if (scopeDecision.Scope == IdeHealthScope.Project && !string.IsNullOrWhiteSpace(scopeDecision.ProjectPath)) |
| 25 | { |
| 26 | var projectPath = scopeDecision.ProjectPath; |
| 27 | return new IdeHealthBuildTestsSnapshot( |
| 28 | IdeHealthFormattingUnit.Default.ProjectBuildSegment(projectPath, buildState), |
| 29 | IdeHealthFormattingUnit.Default.ProjectTestsSegment(projectPath, testSummary, impactedTestsBadge)); |
| 30 | } |
| 31 | |
| 32 | return new IdeHealthBuildTestsSnapshot( |
| 33 | IdeHealthFormattingUnit.Default.BuildSegment(buildState), |
| 34 | IdeHealthFormattingUnit.Default.TestsSegment(testSummary, impactedTestsBadge)); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | public readonly record struct IdeHealthBuildTestsSnapshot( |
| 39 | IdeHealthSegmentInput Build, |
| 40 | IdeHealthSegmentInput Tests); |
| 41 | |