Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
6.0
7.0
9.0
10.0

- name: Cache Tools
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "9.0.306",
"version": "10.0.100",
"rollForward": "latestFeature"
}
}
29 changes: 25 additions & 4 deletions src/Cake.AzurePipelines.Module/AzurePipelinesReportPrinter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Text;
using Cake.Common.Build;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Module.Shared;
using JetBrains.Annotations;
Expand Down Expand Up @@ -53,6 +55,8 @@ public override void Write(CakeReport report)

private void WriteToMarkdown(CakeReport report)
{
var includeSkippedReasonColumn = report.Any(r => !string.IsNullOrEmpty(r.SkippedMessage));

var maxTaskNameLength = 29;
foreach (var item in report)
{
Expand All @@ -67,13 +71,30 @@ private void WriteToMarkdown(CakeReport report)

var sb = new StringBuilder();
sb.AppendLine("");
sb.AppendLine("|Task|Duration|");
sb.AppendLine("|:---|-------:|");

if (includeSkippedReasonColumn)
{
sb.AppendLine("|Task|Duration|Status|Skip Reason|");
sb.AppendLine("|:---|-------:|:-----|:----------|");
}
else
{
sb.AppendLine("|Task|Duration|Status|");
sb.AppendLine("|:---|-------:|:-----|");
}

foreach (var item in report)
{
if (ShouldWriteTask(item))
{
sb.AppendLine(string.Format(lineFormat, item.TaskName, FormatDuration(item)));
if (includeSkippedReasonColumn)
{
sb.AppendLine(string.Format(lineFormat, item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus(), item.SkippedMessage));
}
else
{
sb.AppendLine(string.Format(lineFormat, item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus()));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Core" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CakeContrib.Guidelines" Version="1.6.1">
<PackageReference Include="CakeContrib.Guidelines" Version="1.7.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Core" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
3 changes: 2 additions & 1 deletion src/Cake.GitHubActions.Module/GitHubActionsModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Cake.Core;
using Cake.Core;
using Cake.Core.Annotations;
using Cake.Core.Composition;
using Cake.Core.Diagnostics;
Expand All @@ -22,6 +22,7 @@ public void Register(ICakeContainerRegistrar registrar)

registrar.RegisterType<GitHubActionsEngine>().As<ICakeEngine>().Singleton();
registrar.RegisterType<GitHubActionsLog>().As<ICakeLog>().Singleton();
registrar.RegisterType<GitHubActionsReportPrinter>().As<ICakeReportPrinter>().Singleton();
}
}
}
116 changes: 116 additions & 0 deletions src/Cake.GitHubActions.Module/GitHubActionsReportPrinter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using System;
using System.Linq;
using System.Text;
using Cake.Common.Build;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Module.Shared;
using JetBrains.Annotations;

namespace Cake.GitHubActions.Module
{
/// <summary>
/// The GitHub Actions report printer.
/// </summary>
[UsedImplicitly]
public class GitHubActionsReportPrinter : CakeReportPrinterBase
{
/// <summary>
/// Initializes a new instance of the <see cref="GitHubActionsReportPrinter"/> class.
/// </summary>
/// <param name="console">The console.</param>
/// <param name="context">The context.</param>
public GitHubActionsReportPrinter(IConsole console, ICakeContext context)
: base(console, context)
{
}

/// <inheritdoc />
public override void Write(CakeReport report)
{
if (report == null)
{
throw new ArgumentNullException(nameof(report));
}

try
{
if (_context.GitHubActions().IsRunningOnGitHubActions)
{
WriteToMarkdown(report);
}

WriteToConsole(report);
}
finally
{
_console.ResetColor();
}
}

/// <inheritdoc />
public override void WriteLifeCycleStep(string name, Verbosity verbosity)
{
// Intentionally left blank
}

/// <inheritdoc />
public override void WriteSkippedStep(string name, Verbosity verbosity)
{
// Intentionally left blank
}

/// <inheritdoc />
public override void WriteStep(string name, Verbosity verbosity)
{
// Intentionally left blank
}

private void WriteToMarkdown(CakeReport report)
{
var includeSkippedReasonColumn = report.Any(r => !string.IsNullOrEmpty(r.SkippedMessage));

var sb = new StringBuilder();
sb.AppendLine(string.Empty);

if (includeSkippedReasonColumn)
{
sb.AppendLine("|Task|Duration|Status|Skip Reason|");
sb.AppendLine("|----|--------|------|-----------|");
}
else
{
sb.AppendLine("|Task|Duration|Status|");
sb.AppendLine("|----|--------|------|");
}

foreach (var item in report)
{
if (ShouldWriteTask(item))
{
if (includeSkippedReasonColumn)
{
sb.AppendLine(string.Format("|{0}|{1}|{2}|{3}|", item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus(), item.SkippedMessage));
}
else
{
sb.AppendLine(string.Format("|{0}|{1}|{2}|", item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus()));
}
}
}

if (includeSkippedReasonColumn)
{
sb.AppendLine("|||||");
sb.AppendLine(string.Format("|**_{0}_**|**_{1}_**|||", "Total:", GetTotalTime(report)));
}
else
{
sb.AppendLine("||||");
sb.AppendLine(string.Format("|**_{0}_**|**_{1}_**||", "Total:", GetTotalTime(report)));
}

_context.GitHubActions().Commands.SetStepSummary(sb.ToString());
}
}
}
4 changes: 2 additions & 2 deletions src/Cake.GitLabCI.Module/Cake.GitLabCI.Module.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Core" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.Module.Shared/Cake.Module.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Core" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
22 changes: 19 additions & 3 deletions src/Cake.Module.Shared/CakeReportPrinterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
/// Gets the <see cref="ICakeContext"/>.
/// </summary>
// ReSharper disable once SA1401
protected readonly ICakeContext _context;

Check warning on line 19 in src/Cake.Module.Shared/CakeReportPrinterBase.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Check warning on line 19 in src/Cake.Module.Shared/CakeReportPrinterBase.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)


/// <summary>
/// Gets the <see cref="IConsole"/>.
/// </summary>
// ReSharper disable once SA1401
protected readonly IConsole _console;

Check warning on line 25 in src/Cake.Module.Shared/CakeReportPrinterBase.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Check warning on line 25 in src/Cake.Module.Shared/CakeReportPrinterBase.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)


/// <summary>
/// Initializes a new instance of the <see cref="CakeReportPrinterBase"/> class.
Expand Down Expand Up @@ -63,6 +63,8 @@
/// <param name="report">The report to write.</param>
protected void WriteToConsole(CakeReport report)
{
var includeSkippedReasonColumn = report.Any(r => !string.IsNullOrEmpty(r.SkippedMessage));

var maxTaskNameLength = 29;
foreach (var item in report)
{
Expand All @@ -78,7 +80,14 @@

// Write header.
_console.WriteLine();
_console.WriteLine(lineFormat, "Task", "Duration");
if (includeSkippedReasonColumn)
{
_console.WriteLine(lineFormat, "Task", "Duration", "Status", "Skip Reason");
}
else
{
_console.WriteLine(lineFormat, "Task", "Duration", "Status");
}

Check warning on line 90 in src/Cake.Module.Shared/CakeReportPrinterBase.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Check warning on line 90 in src/Cake.Module.Shared/CakeReportPrinterBase.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

_console.WriteLine(new string('-', 20 + maxTaskNameLength));

// Write task status.
Expand All @@ -87,7 +96,14 @@
if (ShouldWriteTask(item))
{
_console.ForegroundColor = GetItemForegroundColor(item);
_console.WriteLine(lineFormat, item.TaskName, FormatDuration(item));
if (includeSkippedReasonColumn)
{
_console.WriteLine(lineFormat, item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus(), item.SkippedMessage);
}
else
{
_console.WriteLine(lineFormat, item.TaskName, FormatDuration(item), item.ExecutionStatus.ToReportStatus());
}
}
}

Expand Down Expand Up @@ -117,7 +133,7 @@
/// </summary>
/// <param name="time">The <see cref="TimeSpan"/> to format.</param>
/// <returns>A formatted string.</returns>
protected static string FormatTime(TimeSpan time)

Check warning on line 136 in src/Cake.Module.Shared/CakeReportPrinterBase.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Check warning on line 136 in src/Cake.Module.Shared/CakeReportPrinterBase.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

{
return time.ToString("c", CultureInfo.InvariantCulture);
}
Expand All @@ -142,7 +158,7 @@
{
if (item.ExecutionStatus == CakeTaskExecutionStatus.Skipped)
{
return "Skipped";
return "-";
}

return FormatTime(item.Duration);
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.MyGet.Module/Cake.MyGet.Module.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Core" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Core" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="5.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Core" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading