Skip to content

Commit 8e0b355

Browse files
committed
(maint) Update output to include status info
Update the default output, as well as the Azure Pipelines output, to include information about the status of the task, and all the skip reason, if there is something. This change brings consistency to the output after the addition of the new GitHub Actions Report Printer.
1 parent 2e600ce commit 8e0b355

2 files changed

Lines changed: 44 additions & 7 deletions

File tree

src/Cake.AzurePipelines.Module/AzurePipelinesReportPrinter.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
using System;
1+
using System;
22
using System.IO;
3+
using System.Linq;
34
using System.Text;
45
using Cake.Common.Build;
56
using Cake.Core;
7+
using Cake.Core.Diagnostics;
68
using Cake.Core.IO;
79
using Cake.Module.Shared;
810
using JetBrains.Annotations;
@@ -53,6 +55,8 @@ public override void Write(CakeReport report)
5355

5456
private void WriteToMarkdown(CakeReport report)
5557
{
58+
var includeSkippedReasonColumn = report.Any(r => !string.IsNullOrEmpty(r.SkippedMessage));
59+
5660
var maxTaskNameLength = 29;
5761
foreach (var item in report)
5862
{
@@ -67,13 +71,30 @@ private void WriteToMarkdown(CakeReport report)
6771

6872
var sb = new StringBuilder();
6973
sb.AppendLine("");
70-
sb.AppendLine("|Task|Duration|");
71-
sb.AppendLine("|:---|-------:|");
74+
75+
if (includeSkippedReasonColumn)
76+
{
77+
sb.AppendLine("|Task|Duration|Status|Skip Reason|");
78+
sb.AppendLine("|:---|-------:|:-----|:----------|");
79+
}
80+
else
81+
{
82+
sb.AppendLine("|Task|Duration|Status|");
83+
sb.AppendLine("|:---|-------:|:-----|");
84+
}
85+
7286
foreach (var item in report)
7387
{
7488
if (ShouldWriteTask(item))
7589
{
76-
sb.AppendLine(string.Format(lineFormat, item.TaskName, FormatDuration(item)));
90+
if (includeSkippedReasonColumn)
91+
{
92+
sb.AppendLine(string.Format(lineFormat, item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus(), item.SkippedMessage));
93+
}
94+
else
95+
{
96+
sb.AppendLine(string.Format(lineFormat, item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus()));
97+
}
7798
}
7899
}
79100

src/Cake.Module.Shared/CakeReportPrinterBase.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public virtual void WriteSkippedStep(string name, Verbosity verbosity)
6363
/// <param name="report">The report to write.</param>
6464
protected void WriteToConsole(CakeReport report)
6565
{
66+
var includeSkippedReasonColumn = report.Any(r => !string.IsNullOrEmpty(r.SkippedMessage));
67+
6668
var maxTaskNameLength = 29;
6769
foreach (var item in report)
6870
{
@@ -78,7 +80,14 @@ protected void WriteToConsole(CakeReport report)
7880

7981
// Write header.
8082
_console.WriteLine();
81-
_console.WriteLine(lineFormat, "Task", "Duration");
83+
if (includeSkippedReasonColumn)
84+
{
85+
_console.WriteLine(lineFormat, "Task", "Duration", "Status", "Skip Reason");
86+
}
87+
else
88+
{
89+
_console.WriteLine(lineFormat, "Task", "Duration", "Status");
90+
}
8291
_console.WriteLine(new string('-', 20 + maxTaskNameLength));
8392

8493
// Write task status.
@@ -87,7 +96,14 @@ protected void WriteToConsole(CakeReport report)
8796
if (ShouldWriteTask(item))
8897
{
8998
_console.ForegroundColor = GetItemForegroundColor(item);
90-
_console.WriteLine(lineFormat, item.TaskName, FormatDuration(item));
99+
if (includeSkippedReasonColumn)
100+
{
101+
_console.WriteLine(lineFormat, item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus(), item.SkippedMessage);
102+
}
103+
else
104+
{
105+
_console.WriteLine(lineFormat, item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus());
106+
}
91107
}
92108
}
93109

@@ -142,7 +158,7 @@ protected static string FormatDuration(CakeReportEntry item)
142158
{
143159
if (item.ExecutionStatus == CakeTaskExecutionStatus.Skipped)
144160
{
145-
return "Skipped";
161+
return "-";
146162
}
147163

148164
return FormatTime(item.Duration);

0 commit comments

Comments
 (0)