diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 4903ba5f..dd76b6d1 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "1.3.0", + "version": "2.3.0", "commands": [ "dotnet-cake" ] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 70689ad6..f721366b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-2022, ubuntu-22.04] + os: [windows-2022, ubuntu-24.04, macos-13] env: AZURE_PASSWORD: ${{ secrets.AZURE_PASSWORD }} @@ -44,29 +44,43 @@ jobs: steps: - name: Checkout the repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 - name: Fetch all tags and branches run: git fetch --prune --unshallow # codecov and unittests need 2.1, gitversion needs 5.0 - - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 + # GitReleasemanager needs 7.0 + # builds run on 9.0 + - uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1 with: dotnet-version: | 2.1 3.1 5.0 6.0 + 7.0 9.0 - + 10.0 + - name: Install mono + if: runner.os == 'Linux' + # check https://www.mono-project.com/download/stable/#download-lin + run: | + sudo apt install ca-certificates gnupg + sudo gpg --homedir /tmp --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF + sudo chmod +r /usr/share/keyrings/mono-official-archive-keyring.gpg + echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list + sudo apt update + sudo apt install -y mono-complete + mono --version - name: Cache Tools - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: tools key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }} - name: Build project - uses: cake-build/cake-action@5167c3f6a9e15c76f009de2acdfb9488552bc0b9 # v3 + uses: cake-build/cake-action@d218f1133bb74a1df0b08c89cfd8fc100c09e1a0 # v3 with: script-path: recipe.cake target: CI @@ -75,7 +89,7 @@ jobs: # currently, Cake.Recipe does not upload artifacts when run on gh-actions - name: Upload Issues - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 with: if-no-files-found: warn name: ${{ matrix.os }} Issues @@ -84,7 +98,7 @@ jobs: BuildArtifacts/**/coverlet/*.xml - name: Upload Packages - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 if: runner.os == 'Windows' with: if-no-files-found: warn diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d8f6b107..fe9eea57 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -11,7 +11,7 @@ on: jobs: analyze: name: Analyze - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false @@ -20,11 +20,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 with: fetch-depth: 0 - - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 + - uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1 with: dotnet-version: | 2.1 @@ -35,23 +35,35 @@ jobs: 8.0 9.0 + - name: Install mono + if: runner.os == 'Linux' + # check https://www.mono-project.com/download/stable/#download-lin + run: | + sudo apt install ca-certificates gnupg + sudo gpg --homedir /tmp --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF + sudo chmod +r /usr/share/keyrings/mono-official-archive-keyring.gpg + echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list + sudo apt update + sudo apt install -y mono-complete + mono --version + - name: Cache Tools - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: tools key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }} - name: Initialize CodeQL - uses: github/codeql-action/init@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3 + uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 with: languages: ${{ matrix.language }} - name: Build project - uses: cake-build/cake-action@5167c3f6a9e15c76f009de2acdfb9488552bc0b9 # v3 + uses: cake-build/cake-action@d218f1133bb74a1df0b08c89cfd8fc100c09e1a0 # v3 with: script-path: recipe.cake target: DotNetCore-Build cake-version: tool-manifest - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3 + uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4 diff --git a/demo/dsl/.config/dotnet-tools.json b/demo/dsl/.config/dotnet-tools.json index da200cda..ebf1316f 100644 --- a/demo/dsl/.config/dotnet-tools.json +++ b/demo/dsl/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "4.0.0", + "version": "6.0.0", "commands": [ "dotnet-cake" ] diff --git a/demo/frosting/build/Build.csproj b/demo/frosting/build/Build.csproj index 05944909..ace05b93 100644 --- a/demo/frosting/build/Build.csproj +++ b/demo/frosting/build/Build.csproj @@ -5,8 +5,8 @@ $(MSBuildProjectDirectory) - - + + diff --git a/global.json b/global.json index 730de979..45f72329 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.301", + "version": "10.0.100", "rollForward": "latestFeature" } } diff --git a/recipe.cake b/recipe.cake index 1be0a828..841a3bd3 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,4 @@ -#load nuget:?package=Cake.Recipe&version=3.1.1 +#load nuget:?package=Cake.Recipe&version=4.0.0 Environment.SetVariableNames(); @@ -12,7 +12,6 @@ BuildParameters.SetParameters( repositoryOwner: "cake-contrib", shouldRunDotNetCorePack: true, shouldUseDeterministicBuilds: true, - gitterMessage: "@/all " + standardNotificationMessage, twitterMessage: standardNotificationMessage, shouldRunCodecov: false, preferredBuildProviderType: BuildProviderType.GitHubActions, @@ -21,12 +20,6 @@ BuildParameters.SetParameters( BuildParameters.PrintParameters(Context); -ToolSettings.SetToolPreprocessorDirectives( - gitReleaseManagerGlobalTool: "#tool dotnet:?package=GitReleaseManager.Tool&version=0.18.0", - gitVersionGlobalTool: "#tool dotnet:?package=GitVersion.Tool&version=5.12.0", - reportGeneratorGlobalTool: "#tool dotnet:?package=dotnet-reportgenerator-globaltool&version=5.4.7", - coverallsGlobalTool: "#tool dotnet:?package=coveralls.net&version=4.0.1"); - ToolSettings.SetToolSettings(context: Context); Build.RunDotNetCore(); diff --git a/src/Cake.AzurePipelines.Module/AzurePipelinesReportPrinter.cs b/src/Cake.AzurePipelines.Module/AzurePipelinesReportPrinter.cs index 9d81ce10..868c757a 100644 --- a/src/Cake.AzurePipelines.Module/AzurePipelinesReportPrinter.cs +++ b/src/Cake.AzurePipelines.Module/AzurePipelinesReportPrinter.cs @@ -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; @@ -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) { @@ -67,17 +71,37 @@ 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("|:---|-------:|:-----|"); + } + + var targetName = string.Empty; 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())); + } } + + targetName = item.TaskName; // Use the last task name it is the target name } - sb.AppendLine(""); + sb.AppendLine(string.Empty); var b = _context.BuildSystem().AzurePipelines; FilePath agentWorkPath = b.Environment.Build.ArtifactStagingDirectory + "/tasksummary.md"; var absFilePath = agentWorkPath.MakeAbsolute(_context.Environment); @@ -87,7 +111,7 @@ private void WriteToMarkdown(CakeReport report) writer.Write(sb.ToString()); } - _console.WriteLine($"##vso[task.addattachment type=Distributedtask.Core.Summary;name=Cake Build Summary;]{absFilePath.MakeAbsolute(_context.Environment).FullPath}"); + _console.WriteLine($"##vso[task.addattachment type=Distributedtask.Core.Summary;name=Cake {targetName} Build Summary;]{absFilePath.MakeAbsolute(_context.Environment).FullPath}"); } } } diff --git a/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj b/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj index f80b646d..a9f2c850 100644 --- a/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj +++ b/src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj @@ -12,9 +12,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj b/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj index d33193f4..1f01a3fa 100644 --- a/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj +++ b/src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj @@ -58,7 +58,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.GitHubActions.Module/Cake.GitHubActions.Module.csproj b/src/Cake.GitHubActions.Module/Cake.GitHubActions.Module.csproj index 68cd314e..5d74c788 100644 --- a/src/Cake.GitHubActions.Module/Cake.GitHubActions.Module.csproj +++ b/src/Cake.GitHubActions.Module/Cake.GitHubActions.Module.csproj @@ -12,9 +12,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.GitHubActions.Module/GitHubActionsModule.cs b/src/Cake.GitHubActions.Module/GitHubActionsModule.cs index 4816d7d2..da21d5f6 100644 --- a/src/Cake.GitHubActions.Module/GitHubActionsModule.cs +++ b/src/Cake.GitHubActions.Module/GitHubActionsModule.cs @@ -1,4 +1,4 @@ -using Cake.Core; +using Cake.Core; using Cake.Core.Annotations; using Cake.Core.Composition; using Cake.Core.Diagnostics; @@ -22,6 +22,7 @@ public void Register(ICakeContainerRegistrar registrar) registrar.RegisterType().As().Singleton(); registrar.RegisterType().As().Singleton(); + registrar.RegisterType().As().Singleton(); } } } diff --git a/src/Cake.GitHubActions.Module/GitHubActionsReportPrinter.cs b/src/Cake.GitHubActions.Module/GitHubActionsReportPrinter.cs new file mode 100644 index 00000000..f761d25e --- /dev/null +++ b/src/Cake.GitHubActions.Module/GitHubActionsReportPrinter.cs @@ -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 +{ + /// + /// The GitHub Actions report printer. + /// + [UsedImplicitly] + public class GitHubActionsReportPrinter : CakeReportPrinterBase + { + /// + /// Initializes a new instance of the class. + /// + /// The console. + /// The context. + public GitHubActionsReportPrinter(IConsole console, ICakeContext context) + : base(console, context) + { + } + + /// + 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(); + } + } + + /// + public override void WriteLifeCycleStep(string name, Verbosity verbosity) + { + // Intentionally left blank + } + + /// + public override void WriteSkippedStep(string name, Verbosity verbosity) + { + // Intentionally left blank + } + + /// + 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()); + } + } +} diff --git a/src/Cake.GitLabCI.Module/Cake.GitLabCI.Module.csproj b/src/Cake.GitLabCI.Module/Cake.GitLabCI.Module.csproj index 8dd32312..50ef9333 100644 --- a/src/Cake.GitLabCI.Module/Cake.GitLabCI.Module.csproj +++ b/src/Cake.GitLabCI.Module/Cake.GitLabCI.Module.csproj @@ -12,9 +12,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.Module.Shared/Cake.Module.Shared.csproj b/src/Cake.Module.Shared/Cake.Module.Shared.csproj index b0056694..953057b8 100644 --- a/src/Cake.Module.Shared/Cake.Module.Shared.csproj +++ b/src/Cake.Module.Shared/Cake.Module.Shared.csproj @@ -8,9 +8,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.Module.Shared/CakeReportPrinterBase.cs b/src/Cake.Module.Shared/CakeReportPrinterBase.cs index b2c952d6..c2d4e78d 100644 --- a/src/Cake.Module.Shared/CakeReportPrinterBase.cs +++ b/src/Cake.Module.Shared/CakeReportPrinterBase.cs @@ -63,6 +63,8 @@ public virtual void WriteSkippedStep(string name, Verbosity verbosity) /// The report to write. protected void WriteToConsole(CakeReport report) { + var includeSkippedReasonColumn = report.Any(r => !string.IsNullOrEmpty(r.SkippedMessage)); + var maxTaskNameLength = 29; foreach (var item in report) { @@ -78,7 +80,14 @@ protected void WriteToConsole(CakeReport report) // 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"); + } _console.WriteLine(new string('-', 20 + maxTaskNameLength)); // Write task status. @@ -87,7 +96,14 @@ protected void WriteToConsole(CakeReport report) 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()); + } } } @@ -142,7 +158,7 @@ protected static string FormatDuration(CakeReportEntry item) { if (item.ExecutionStatus == CakeTaskExecutionStatus.Skipped) { - return "Skipped"; + return "-"; } return FormatTime(item.Duration); diff --git a/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj b/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj index f74b25d9..fd795917 100644 --- a/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj +++ b/src/Cake.MyGet.Module/Cake.MyGet.Module.csproj @@ -12,9 +12,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj b/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj index 8d663ad4..6ba6fcb1 100644 --- a/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj +++ b/src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj @@ -12,9 +12,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj b/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj index ba7b4919..c7d60f18 100644 --- a/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj +++ b/src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj @@ -12,9 +12,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all