From a0e8a83a8f6206ede2c804919f42caa45ed312c5 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 19:17:36 -0500 Subject: [PATCH 01/32] Drop special formatting, allowing annotations to work properly. --- build/DalamudBuild.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 6340c36fa..b3ef9ec17 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -8,6 +8,7 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; +using Serilog.Events; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild @@ -61,6 +62,8 @@ public class DalamudBuild : NukeBuild private static Dictionary EnvironmentVariables => new(EnvironmentInfo.Variables); + private static string ConsoleTemplate => "{Message:l}{NewLine}{Exception}"; + Target Restore => _ => _ .Executes(() => { @@ -159,7 +162,15 @@ public class DalamudBuild : NukeBuild .SetConfiguration(Configuration)); }); + Target SetCustomLogging => _ => _ + .Executes(() => + { + var config = new LoggerConfiguration().WriteTo.Console(outputTemplate: ConsoleTemplate, restrictedToMinimumLevel: LogEventLevel.Debug).ConfigureFiles(this); + Log.Logger = config.CreateLogger(); + }); + Target Compile => _ => _ + .DependsOn(SetCustomLogging) .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) From 3f803adcf144674cff36b659340777502541c5ee Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 20:20:47 -0500 Subject: [PATCH 02/32] Suppress duplicate warnings, adding a prefix to prevent annotation --- .nuke/build.schema.json | 2 ++ build/DalamudBuild.cs | 38 ++++++++++++++++++++++++++++---------- build/build.csproj | 1 + 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index e7e1a446a..0dcc7c47a 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -88,6 +88,7 @@ "CompileInjector", "CompileInjectorBoot", "Restore", + "SetCustomLogging", "Test" ] } @@ -114,6 +115,7 @@ "CompileInjector", "CompileInjectorBoot", "Restore", + "SetCustomLogging", "Test" ] } diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index b3ef9ec17..630994238 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.IO; +using System.Linq; using Nuke.Common; using Nuke.Common.Execution; using Nuke.Common.Git; @@ -8,7 +9,9 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; +using Serilog.Configuration; using Serilog.Events; +using Serilog.Sinks.Intercepter; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild @@ -163,19 +166,33 @@ public class DalamudBuild : NukeBuild }); Target SetCustomLogging => _ => _ - .Executes(() => + .Executes(() => + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.Conditional(c => AllowMessage(c), wt => wt.Console(outputTemplate: ConsoleTemplate)) + .CreateLogger(); + }); + + private static readonly HashSet MessageBuffer = []; + private static bool AllowMessage(LogEvent e) { - var config = new LoggerConfiguration().WriteTo.Console(outputTemplate: ConsoleTemplate, restrictedToMinimumLevel: LogEventLevel.Debug).ConfigureFiles(this); - Log.Logger = config.CreateLogger(); - }); + if (e.Level == LogEventLevel.Warning && MessageBuffer.Contains(e.MessageTemplate.Text)) + { + Log.Debug($"Suppressing duplicate warning: {e.MessageTemplate.Text}"); + return false; + } + MessageBuffer.Add(e.MessageTemplate.Text); + return true; + } Target Compile => _ => _ - .DependsOn(SetCustomLogging) - .DependsOn(CompileDalamud) - .DependsOn(CompileDalamudBoot) - .DependsOn(CompileDalamudCrashHandler) - .DependsOn(CompileInjector) - .DependsOn(CompileInjectorBoot); + .DependsOn(SetCustomLogging) + .DependsOn(CompileDalamud) + .DependsOn(CompileDalamudBoot) + .DependsOn(CompileDalamudCrashHandler) + .DependsOn(CompileInjector) + .DependsOn(CompileInjectorBoot); Target Test => _ => _ .DependsOn(Compile) @@ -184,6 +201,7 @@ public class DalamudBuild : NukeBuild DotNetTasks.DotNetTest(s => s .SetProjectFile(TestProjectFile) .SetConfiguration(Configuration) + .AddProperty("WarningLevel", "0") .EnableNoRestore()); }); diff --git a/build/build.csproj b/build/build.csproj index 219b668bd..a8e2cb846 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -12,5 +12,6 @@ + From fceea19437c91687c2f6f86f2f1ba527aeabbec2 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 20:37:11 -0500 Subject: [PATCH 03/32] Tweak message, don't rebuild on test --- build/DalamudBuild.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 630994238..2b332d1fc 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -179,7 +179,7 @@ private static bool AllowMessage(LogEvent e) { if (e.Level == LogEventLevel.Warning && MessageBuffer.Contains(e.MessageTemplate.Text)) { - Log.Debug($"Suppressing duplicate warning: {e.MessageTemplate.Text}"); + Log.Debug($"Suppressing duplicate message: {e.MessageTemplate.Text.Replace("warning","dupwarn")}"); return false; } MessageBuffer.Add(e.MessageTemplate.Text); From 2c11a395e680e89c90240eca7bfe8d965a26d0f3 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 20:49:51 -0500 Subject: [PATCH 04/32] Move testing into same job step --- .github/workflows/main.yml | 4 +--- build/DalamudBuild.cs | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 930adf8ed..747e2d462 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,10 +32,8 @@ jobs: ($env:REPO_NAME) >> VERSION ($env:BRANCH) >> VERSION ($env:COMMIT) >> VERSION - - name: Build Dalamud + - name: Build and Test Dalamud run: .\build.ps1 compile - - name: Test Dalamud - run: .\build.ps1 test - name: Sign Dalamud if: ${{ github.repository_owner == 'goatcorp' && github.event_name == 'push' }} env: diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 2b332d1fc..4b3086e08 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -192,16 +192,16 @@ private static bool AllowMessage(LogEvent e) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) .DependsOn(CompileInjector) - .DependsOn(CompileInjectorBoot); + .DependsOn(CompileInjectorBoot) + .DependsOn(Test); Target Test => _ => _ - .DependsOn(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s .SetProjectFile(TestProjectFile) .SetConfiguration(Configuration) - .AddProperty("WarningLevel", "0") + .SetNoBuild(true) .EnableNoRestore()); }); From 18afb45d468e2b237582454f4c8a904d1aff1a55 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:07:43 -0500 Subject: [PATCH 05/32] Only run PR build on newly opened PRs --- .github/workflows/main.yml | 6 +++++- build/DalamudBuild.cs | 3 --- build/build.csproj | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 747e2d462..710bca992 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,9 @@ name: Build Dalamud -on: [push, pull_request, workflow_dispatch] +on: + push: + pull_request: + types: [opened] + workflow_dispatch: concurrency: group: build_dalamud_${{ github.ref_name }} cancel-in-progress: true diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 4b3086e08..a15444274 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.IO; -using System.Linq; using Nuke.Common; using Nuke.Common.Execution; using Nuke.Common.Git; @@ -9,9 +8,7 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; -using Serilog.Configuration; using Serilog.Events; -using Serilog.Sinks.Intercepter; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild diff --git a/build/build.csproj b/build/build.csproj index a8e2cb846..219b668bd 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -12,6 +12,5 @@ - From 9ba0f4ece2aaf3e81f33938e33d6da8df1965e86 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:11:45 -0500 Subject: [PATCH 06/32] flip build order, derp --- build/DalamudBuild.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index a15444274..fd62f7d71 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -184,13 +184,13 @@ private static bool AllowMessage(LogEvent e) } Target Compile => _ => _ - .DependsOn(SetCustomLogging) + .DependsOn(Test) .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) .DependsOn(CompileInjector) .DependsOn(CompileInjectorBoot) - .DependsOn(Test); + .DependsOn(SetCustomLogging); Target Test => _ => _ .Executes(() => From 349dd06647759bba08b64828ea218b3ae73038aa Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:26:15 -0500 Subject: [PATCH 07/32] Test suppressing summary for annotations... --- build/DalamudBuild.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index fd62f7d71..43c3810b4 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -5,6 +5,7 @@ using Nuke.Common.Git; using Nuke.Common.IO; using Nuke.Common.ProjectModel; +using Nuke.Common.Tooling; using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; @@ -113,6 +114,7 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) + .SetProcessArgumentConfigurator(a => a.Add("/clp:ErrorsOnly")) .EnableNoRestore(); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly @@ -167,7 +169,7 @@ public class DalamudBuild : NukeBuild { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() - .WriteTo.Conditional(c => AllowMessage(c), wt => wt.Console(outputTemplate: ConsoleTemplate)) + .WriteTo.Console(outputTemplate: ConsoleTemplate) //Conditional(c => AllowMessage(c), wt => wt. .CreateLogger(); }); @@ -184,7 +186,6 @@ private static bool AllowMessage(LogEvent e) } Target Compile => _ => _ - .DependsOn(Test) .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) @@ -193,6 +194,7 @@ private static bool AllowMessage(LogEvent e) .DependsOn(SetCustomLogging); Target Test => _ => _ + .DependsOn(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s From 748cd961fd3f5e1151cb62697dbc2772c6af550c Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:36:34 -0500 Subject: [PATCH 08/32] Get the build order right, testing without conditionals... --- build/DalamudBuild.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 43c3810b4..56261cdee 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -114,7 +114,7 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) - .SetProcessArgumentConfigurator(a => a.Add("/clp:ErrorsOnly")) + .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")) .EnableNoRestore(); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly @@ -165,6 +165,7 @@ public class DalamudBuild : NukeBuild }); Target SetCustomLogging => _ => _ + .DependentFor(Compile) .Executes(() => { Log.Logger = new LoggerConfiguration() @@ -191,10 +192,10 @@ private static bool AllowMessage(LogEvent e) .DependsOn(CompileDalamudCrashHandler) .DependsOn(CompileInjector) .DependsOn(CompileInjectorBoot) - .DependsOn(SetCustomLogging); + ; Target Test => _ => _ - .DependsOn(Compile) + .TriggeredBy(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s From 89d4711eda4e61944569125d6fb68d9c02ae5678 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:49:18 -0500 Subject: [PATCH 09/32] Run tests after compile, suppress warnings from test --- build/DalamudBuild.cs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 56261cdee..f591aae64 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -9,7 +9,6 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; -using Serilog.Events; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild @@ -114,8 +113,8 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) - .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")) - .EnableNoRestore(); + .EnableNoRestore() + .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly // TODO: This fails every build after this because of redefinitions... @@ -170,22 +169,10 @@ public class DalamudBuild : NukeBuild { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() - .WriteTo.Console(outputTemplate: ConsoleTemplate) //Conditional(c => AllowMessage(c), wt => wt. + .WriteTo.Console(outputTemplate: ConsoleTemplate) .CreateLogger(); }); - private static readonly HashSet MessageBuffer = []; - private static bool AllowMessage(LogEvent e) - { - if (e.Level == LogEventLevel.Warning && MessageBuffer.Contains(e.MessageTemplate.Text)) - { - Log.Debug($"Suppressing duplicate message: {e.MessageTemplate.Text.Replace("warning","dupwarn")}"); - return false; - } - MessageBuffer.Add(e.MessageTemplate.Text); - return true; - } - Target Compile => _ => _ .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) @@ -201,7 +188,7 @@ private static bool AllowMessage(LogEvent e) DotNetTasks.DotNetTest(s => s .SetProjectFile(TestProjectFile) .SetConfiguration(Configuration) - .SetNoBuild(true) + .AddProperty("WarningLevel", "0") .EnableNoRestore()); }); From ad133d86783985d91ac3ff6042af330ceffd2866 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Tue, 24 Dec 2024 13:35:31 -0500 Subject: [PATCH 10/32] Reverted previous change to `main.yml`. --- .github/workflows/main.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 710bca992..09e99b84f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,6 @@ name: Build Dalamud -on: - push: - pull_request: - types: [opened] - workflow_dispatch: +on: [push, pull_request, workflow_dispatch] + concurrency: group: build_dalamud_${{ github.ref_name }} cancel-in-progress: true From 9df01d18c344b7cd96a856fe94fd345c85db81c4 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 19:17:36 -0500 Subject: [PATCH 11/32] Drop special formatting, allowing annotations to work properly. --- build/DalamudBuild.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 6340c36fa..b3ef9ec17 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -8,6 +8,7 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; +using Serilog.Events; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild @@ -61,6 +62,8 @@ public class DalamudBuild : NukeBuild private static Dictionary EnvironmentVariables => new(EnvironmentInfo.Variables); + private static string ConsoleTemplate => "{Message:l}{NewLine}{Exception}"; + Target Restore => _ => _ .Executes(() => { @@ -159,7 +162,15 @@ public class DalamudBuild : NukeBuild .SetConfiguration(Configuration)); }); + Target SetCustomLogging => _ => _ + .Executes(() => + { + var config = new LoggerConfiguration().WriteTo.Console(outputTemplate: ConsoleTemplate, restrictedToMinimumLevel: LogEventLevel.Debug).ConfigureFiles(this); + Log.Logger = config.CreateLogger(); + }); + Target Compile => _ => _ + .DependsOn(SetCustomLogging) .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) From e173e450a27ac1d02aa7c834743adb17e5ad5c72 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 20:20:47 -0500 Subject: [PATCH 12/32] Suppress duplicate warnings, adding a prefix to prevent annotation --- .nuke/build.schema.json | 2 ++ build/DalamudBuild.cs | 38 ++++++++++++++++++++++++++++---------- build/build.csproj | 1 + 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index e7e1a446a..0dcc7c47a 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -88,6 +88,7 @@ "CompileInjector", "CompileInjectorBoot", "Restore", + "SetCustomLogging", "Test" ] } @@ -114,6 +115,7 @@ "CompileInjector", "CompileInjectorBoot", "Restore", + "SetCustomLogging", "Test" ] } diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index b3ef9ec17..630994238 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.IO; +using System.Linq; using Nuke.Common; using Nuke.Common.Execution; using Nuke.Common.Git; @@ -8,7 +9,9 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; +using Serilog.Configuration; using Serilog.Events; +using Serilog.Sinks.Intercepter; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild @@ -163,19 +166,33 @@ public class DalamudBuild : NukeBuild }); Target SetCustomLogging => _ => _ - .Executes(() => + .Executes(() => + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.Conditional(c => AllowMessage(c), wt => wt.Console(outputTemplate: ConsoleTemplate)) + .CreateLogger(); + }); + + private static readonly HashSet MessageBuffer = []; + private static bool AllowMessage(LogEvent e) { - var config = new LoggerConfiguration().WriteTo.Console(outputTemplate: ConsoleTemplate, restrictedToMinimumLevel: LogEventLevel.Debug).ConfigureFiles(this); - Log.Logger = config.CreateLogger(); - }); + if (e.Level == LogEventLevel.Warning && MessageBuffer.Contains(e.MessageTemplate.Text)) + { + Log.Debug($"Suppressing duplicate warning: {e.MessageTemplate.Text}"); + return false; + } + MessageBuffer.Add(e.MessageTemplate.Text); + return true; + } Target Compile => _ => _ - .DependsOn(SetCustomLogging) - .DependsOn(CompileDalamud) - .DependsOn(CompileDalamudBoot) - .DependsOn(CompileDalamudCrashHandler) - .DependsOn(CompileInjector) - .DependsOn(CompileInjectorBoot); + .DependsOn(SetCustomLogging) + .DependsOn(CompileDalamud) + .DependsOn(CompileDalamudBoot) + .DependsOn(CompileDalamudCrashHandler) + .DependsOn(CompileInjector) + .DependsOn(CompileInjectorBoot); Target Test => _ => _ .DependsOn(Compile) @@ -184,6 +201,7 @@ public class DalamudBuild : NukeBuild DotNetTasks.DotNetTest(s => s .SetProjectFile(TestProjectFile) .SetConfiguration(Configuration) + .AddProperty("WarningLevel", "0") .EnableNoRestore()); }); diff --git a/build/build.csproj b/build/build.csproj index 219b668bd..a8e2cb846 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -12,5 +12,6 @@ + From e0d18a9d1d57c87f5a1773d60210aace639b26f7 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 20:37:11 -0500 Subject: [PATCH 13/32] Tweak message, don't rebuild on test --- build/DalamudBuild.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 630994238..2b332d1fc 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -179,7 +179,7 @@ private static bool AllowMessage(LogEvent e) { if (e.Level == LogEventLevel.Warning && MessageBuffer.Contains(e.MessageTemplate.Text)) { - Log.Debug($"Suppressing duplicate warning: {e.MessageTemplate.Text}"); + Log.Debug($"Suppressing duplicate message: {e.MessageTemplate.Text.Replace("warning","dupwarn")}"); return false; } MessageBuffer.Add(e.MessageTemplate.Text); From a023e1dd09557f6ac7b1d2f40cefc3735451c45b Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 20:49:51 -0500 Subject: [PATCH 14/32] Move testing into same job step --- .github/workflows/main.yml | 4 +--- build/DalamudBuild.cs | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 930adf8ed..747e2d462 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,10 +32,8 @@ jobs: ($env:REPO_NAME) >> VERSION ($env:BRANCH) >> VERSION ($env:COMMIT) >> VERSION - - name: Build Dalamud + - name: Build and Test Dalamud run: .\build.ps1 compile - - name: Test Dalamud - run: .\build.ps1 test - name: Sign Dalamud if: ${{ github.repository_owner == 'goatcorp' && github.event_name == 'push' }} env: diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 2b332d1fc..4b3086e08 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -192,16 +192,16 @@ private static bool AllowMessage(LogEvent e) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) .DependsOn(CompileInjector) - .DependsOn(CompileInjectorBoot); + .DependsOn(CompileInjectorBoot) + .DependsOn(Test); Target Test => _ => _ - .DependsOn(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s .SetProjectFile(TestProjectFile) .SetConfiguration(Configuration) - .AddProperty("WarningLevel", "0") + .SetNoBuild(true) .EnableNoRestore()); }); From c7ee6b0440bf7881af29148baa0f3105ddafa19a Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:07:43 -0500 Subject: [PATCH 15/32] Only run PR build on newly opened PRs --- .github/workflows/main.yml | 6 +++++- build/DalamudBuild.cs | 3 --- build/build.csproj | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 747e2d462..710bca992 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,9 @@ name: Build Dalamud -on: [push, pull_request, workflow_dispatch] +on: + push: + pull_request: + types: [opened] + workflow_dispatch: concurrency: group: build_dalamud_${{ github.ref_name }} cancel-in-progress: true diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 4b3086e08..a15444274 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.IO; -using System.Linq; using Nuke.Common; using Nuke.Common.Execution; using Nuke.Common.Git; @@ -9,9 +8,7 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; -using Serilog.Configuration; using Serilog.Events; -using Serilog.Sinks.Intercepter; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild diff --git a/build/build.csproj b/build/build.csproj index a8e2cb846..219b668bd 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -12,6 +12,5 @@ - From 9b8f637b7350119d4709d5da578c95b8948d2155 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:11:45 -0500 Subject: [PATCH 16/32] flip build order, derp --- build/DalamudBuild.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index a15444274..fd62f7d71 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -184,13 +184,13 @@ private static bool AllowMessage(LogEvent e) } Target Compile => _ => _ - .DependsOn(SetCustomLogging) + .DependsOn(Test) .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) .DependsOn(CompileInjector) .DependsOn(CompileInjectorBoot) - .DependsOn(Test); + .DependsOn(SetCustomLogging); Target Test => _ => _ .Executes(() => From aa04419dfa8b915eb453843fa5d6fed01912b3f9 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:26:15 -0500 Subject: [PATCH 17/32] Test suppressing summary for annotations... --- build/DalamudBuild.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index fd62f7d71..43c3810b4 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -5,6 +5,7 @@ using Nuke.Common.Git; using Nuke.Common.IO; using Nuke.Common.ProjectModel; +using Nuke.Common.Tooling; using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; @@ -113,6 +114,7 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) + .SetProcessArgumentConfigurator(a => a.Add("/clp:ErrorsOnly")) .EnableNoRestore(); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly @@ -167,7 +169,7 @@ public class DalamudBuild : NukeBuild { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() - .WriteTo.Conditional(c => AllowMessage(c), wt => wt.Console(outputTemplate: ConsoleTemplate)) + .WriteTo.Console(outputTemplate: ConsoleTemplate) //Conditional(c => AllowMessage(c), wt => wt. .CreateLogger(); }); @@ -184,7 +186,6 @@ private static bool AllowMessage(LogEvent e) } Target Compile => _ => _ - .DependsOn(Test) .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) @@ -193,6 +194,7 @@ private static bool AllowMessage(LogEvent e) .DependsOn(SetCustomLogging); Target Test => _ => _ + .DependsOn(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s From 99d4970ba6d33d93bf17fff7f71fd26deef656b3 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:36:34 -0500 Subject: [PATCH 18/32] Get the build order right, testing without conditionals... --- build/DalamudBuild.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 43c3810b4..56261cdee 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -114,7 +114,7 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) - .SetProcessArgumentConfigurator(a => a.Add("/clp:ErrorsOnly")) + .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")) .EnableNoRestore(); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly @@ -165,6 +165,7 @@ public class DalamudBuild : NukeBuild }); Target SetCustomLogging => _ => _ + .DependentFor(Compile) .Executes(() => { Log.Logger = new LoggerConfiguration() @@ -191,10 +192,10 @@ private static bool AllowMessage(LogEvent e) .DependsOn(CompileDalamudCrashHandler) .DependsOn(CompileInjector) .DependsOn(CompileInjectorBoot) - .DependsOn(SetCustomLogging); + ; Target Test => _ => _ - .DependsOn(Compile) + .TriggeredBy(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s From 46984d193f1d0a1455f9014a0e312106a0988405 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:49:18 -0500 Subject: [PATCH 19/32] Run tests after compile, suppress warnings from test --- build/DalamudBuild.cs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 56261cdee..f591aae64 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -9,7 +9,6 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; -using Serilog.Events; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild @@ -114,8 +113,8 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) - .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")) - .EnableNoRestore(); + .EnableNoRestore() + .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly // TODO: This fails every build after this because of redefinitions... @@ -170,22 +169,10 @@ public class DalamudBuild : NukeBuild { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() - .WriteTo.Console(outputTemplate: ConsoleTemplate) //Conditional(c => AllowMessage(c), wt => wt. + .WriteTo.Console(outputTemplate: ConsoleTemplate) .CreateLogger(); }); - private static readonly HashSet MessageBuffer = []; - private static bool AllowMessage(LogEvent e) - { - if (e.Level == LogEventLevel.Warning && MessageBuffer.Contains(e.MessageTemplate.Text)) - { - Log.Debug($"Suppressing duplicate message: {e.MessageTemplate.Text.Replace("warning","dupwarn")}"); - return false; - } - MessageBuffer.Add(e.MessageTemplate.Text); - return true; - } - Target Compile => _ => _ .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) @@ -201,7 +188,7 @@ private static bool AllowMessage(LogEvent e) DotNetTasks.DotNetTest(s => s .SetProjectFile(TestProjectFile) .SetConfiguration(Configuration) - .SetNoBuild(true) + .AddProperty("WarningLevel", "0") .EnableNoRestore()); }); From 470355f40f0d93b38e5ea8fedb4b386a82e9a2fb Mon Sep 17 00:00:00 2001 From: Nathan C Date: Tue, 24 Dec 2024 13:35:31 -0500 Subject: [PATCH 20/32] Reverted previous change to `main.yml`. --- .github/workflows/main.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 710bca992..09e99b84f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,6 @@ name: Build Dalamud -on: - push: - pull_request: - types: [opened] - workflow_dispatch: +on: [push, pull_request, workflow_dispatch] + concurrency: group: build_dalamud_${{ github.ref_name }} cancel-in-progress: true From d5126100c03849c3dc751aca8b850bff02e2cde9 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 19:17:36 -0500 Subject: [PATCH 21/32] Drop special formatting, allowing annotations to work properly. --- build/DalamudBuild.cs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index f591aae64..5325ebb1e 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -9,6 +9,7 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; +using Serilog.Events; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild @@ -164,22 +165,19 @@ public class DalamudBuild : NukeBuild }); Target SetCustomLogging => _ => _ - .DependentFor(Compile) - .Executes(() => - { - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Debug() - .WriteTo.Console(outputTemplate: ConsoleTemplate) - .CreateLogger(); - }); + .Executes(() => + { + var config = new LoggerConfiguration().WriteTo.Console(outputTemplate: ConsoleTemplate, restrictedToMinimumLevel: LogEventLevel.Debug).ConfigureFiles(this); + Log.Logger = config.CreateLogger(); + }); Target Compile => _ => _ - .DependsOn(CompileDalamud) - .DependsOn(CompileDalamudBoot) - .DependsOn(CompileDalamudCrashHandler) - .DependsOn(CompileInjector) - .DependsOn(CompileInjectorBoot) - ; + .DependsOn(SetCustomLogging) + .DependsOn(CompileDalamud) + .DependsOn(CompileDalamudBoot) + .DependsOn(CompileDalamudCrashHandler) + .DependsOn(CompileInjector) + .DependsOn(CompileInjectorBoot); Target Test => _ => _ .TriggeredBy(Compile) From 5d4ba87ccb5f1522a2c4a66f5d81786a47c4fc0c Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 20:20:47 -0500 Subject: [PATCH 22/32] Suppress duplicate warnings, adding a prefix to prevent annotation --- build/DalamudBuild.cs | 37 +++++++++++++++++++++++++++---------- build/build.csproj | 1 + 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 5325ebb1e..3fbf3021d 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.IO; +using System.Linq; using Nuke.Common; using Nuke.Common.Execution; using Nuke.Common.Git; @@ -9,7 +10,9 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; +using Serilog.Configuration; using Serilog.Events; +using Serilog.Sinks.Intercepter; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild @@ -165,19 +168,33 @@ public class DalamudBuild : NukeBuild }); Target SetCustomLogging => _ => _ - .Executes(() => + .Executes(() => + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.Conditional(c => AllowMessage(c), wt => wt.Console(outputTemplate: ConsoleTemplate)) + .CreateLogger(); + }); + + private static readonly HashSet MessageBuffer = []; + private static bool AllowMessage(LogEvent e) { - var config = new LoggerConfiguration().WriteTo.Console(outputTemplate: ConsoleTemplate, restrictedToMinimumLevel: LogEventLevel.Debug).ConfigureFiles(this); - Log.Logger = config.CreateLogger(); - }); + if (e.Level == LogEventLevel.Warning && MessageBuffer.Contains(e.MessageTemplate.Text)) + { + Log.Debug($"Suppressing duplicate warning: {e.MessageTemplate.Text}"); + return false; + } + MessageBuffer.Add(e.MessageTemplate.Text); + return true; + } Target Compile => _ => _ - .DependsOn(SetCustomLogging) - .DependsOn(CompileDalamud) - .DependsOn(CompileDalamudBoot) - .DependsOn(CompileDalamudCrashHandler) - .DependsOn(CompileInjector) - .DependsOn(CompileInjectorBoot); + .DependsOn(SetCustomLogging) + .DependsOn(CompileDalamud) + .DependsOn(CompileDalamudBoot) + .DependsOn(CompileDalamudCrashHandler) + .DependsOn(CompileInjector) + .DependsOn(CompileInjectorBoot); Target Test => _ => _ .TriggeredBy(Compile) diff --git a/build/build.csproj b/build/build.csproj index 219b668bd..a8e2cb846 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -12,5 +12,6 @@ + From cc17905873c987aeae664aac3162c7b550c43fa3 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 20:37:11 -0500 Subject: [PATCH 23/32] Tweak message, don't rebuild on test --- build/DalamudBuild.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 3fbf3021d..6c03f637d 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -181,7 +181,7 @@ private static bool AllowMessage(LogEvent e) { if (e.Level == LogEventLevel.Warning && MessageBuffer.Contains(e.MessageTemplate.Text)) { - Log.Debug($"Suppressing duplicate warning: {e.MessageTemplate.Text}"); + Log.Debug($"Suppressing duplicate message: {e.MessageTemplate.Text.Replace("warning","dupwarn")}"); return false; } MessageBuffer.Add(e.MessageTemplate.Text); From 42a27c3e5129e6f66baf8277aba44a9cfc5e70ff Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 20:49:51 -0500 Subject: [PATCH 24/32] Move testing into same job step --- build/DalamudBuild.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 6c03f637d..95bc7d08b 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -194,16 +194,16 @@ private static bool AllowMessage(LogEvent e) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) .DependsOn(CompileInjector) - .DependsOn(CompileInjectorBoot); + .DependsOn(CompileInjectorBoot) + .DependsOn(Test); Target Test => _ => _ - .TriggeredBy(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s .SetProjectFile(TestProjectFile) .SetConfiguration(Configuration) - .AddProperty("WarningLevel", "0") + .SetNoBuild(true) .EnableNoRestore()); }); From d9599c1b93837f13479ea3a87516d22a24b742cf Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:07:43 -0500 Subject: [PATCH 25/32] Only run PR build on newly opened PRs --- .github/workflows/main.yml | 7 +++++-- build/DalamudBuild.cs | 3 --- build/build.csproj | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09e99b84f..710bca992 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,9 @@ name: Build Dalamud -on: [push, pull_request, workflow_dispatch] - +on: + push: + pull_request: + types: [opened] + workflow_dispatch: concurrency: group: build_dalamud_${{ github.ref_name }} cancel-in-progress: true diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 95bc7d08b..f8ea94f7d 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.IO; -using System.Linq; using Nuke.Common; using Nuke.Common.Execution; using Nuke.Common.Git; @@ -10,9 +9,7 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; -using Serilog.Configuration; using Serilog.Events; -using Serilog.Sinks.Intercepter; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild diff --git a/build/build.csproj b/build/build.csproj index a8e2cb846..219b668bd 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -12,6 +12,5 @@ - From 62362d3b5e41a578f08f264952d6314202a67547 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:11:45 -0500 Subject: [PATCH 26/32] flip build order, derp --- build/DalamudBuild.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index f8ea94f7d..0886e6d42 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -186,13 +186,13 @@ private static bool AllowMessage(LogEvent e) } Target Compile => _ => _ - .DependsOn(SetCustomLogging) + .DependsOn(Test) .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) .DependsOn(CompileInjector) .DependsOn(CompileInjectorBoot) - .DependsOn(Test); + .DependsOn(SetCustomLogging); Target Test => _ => _ .Executes(() => From e1f51a361faac3c6c02d0b89d6fabe643f98d6d0 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:26:15 -0500 Subject: [PATCH 27/32] Test suppressing summary for annotations... --- build/DalamudBuild.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 0886e6d42..43c3810b4 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -114,8 +114,8 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) - .EnableNoRestore() - .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")); + .SetProcessArgumentConfigurator(a => a.Add("/clp:ErrorsOnly")) + .EnableNoRestore(); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly // TODO: This fails every build after this because of redefinitions... @@ -169,7 +169,7 @@ public class DalamudBuild : NukeBuild { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() - .WriteTo.Conditional(c => AllowMessage(c), wt => wt.Console(outputTemplate: ConsoleTemplate)) + .WriteTo.Console(outputTemplate: ConsoleTemplate) //Conditional(c => AllowMessage(c), wt => wt. .CreateLogger(); }); @@ -186,7 +186,6 @@ private static bool AllowMessage(LogEvent e) } Target Compile => _ => _ - .DependsOn(Test) .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) .DependsOn(CompileDalamudCrashHandler) @@ -195,6 +194,7 @@ private static bool AllowMessage(LogEvent e) .DependsOn(SetCustomLogging); Target Test => _ => _ + .DependsOn(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s From a6f50d88106779d400a81622dd6fb589ac0137e9 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:36:34 -0500 Subject: [PATCH 28/32] Get the build order right, testing without conditionals... --- build/DalamudBuild.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 43c3810b4..56261cdee 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -114,7 +114,7 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) - .SetProcessArgumentConfigurator(a => a.Add("/clp:ErrorsOnly")) + .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")) .EnableNoRestore(); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly @@ -165,6 +165,7 @@ public class DalamudBuild : NukeBuild }); Target SetCustomLogging => _ => _ + .DependentFor(Compile) .Executes(() => { Log.Logger = new LoggerConfiguration() @@ -191,10 +192,10 @@ private static bool AllowMessage(LogEvent e) .DependsOn(CompileDalamudCrashHandler) .DependsOn(CompileInjector) .DependsOn(CompileInjectorBoot) - .DependsOn(SetCustomLogging); + ; Target Test => _ => _ - .DependsOn(Compile) + .TriggeredBy(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s From 7031ff9c3b9b92b2a32b4306c4ad3eeefb7ad20e Mon Sep 17 00:00:00 2001 From: Nathan C Date: Mon, 23 Dec 2024 21:49:18 -0500 Subject: [PATCH 29/32] Run tests after compile, suppress warnings from test --- build/DalamudBuild.cs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 56261cdee..f591aae64 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -9,7 +9,6 @@ using Nuke.Common.Tools.DotNet; using Nuke.Common.Tools.MSBuild; using Serilog; -using Serilog.Events; [UnsetVisualStudioEnvironmentVariables] public class DalamudBuild : NukeBuild @@ -114,8 +113,8 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) - .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")) - .EnableNoRestore(); + .EnableNoRestore() + .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly // TODO: This fails every build after this because of redefinitions... @@ -170,22 +169,10 @@ public class DalamudBuild : NukeBuild { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() - .WriteTo.Console(outputTemplate: ConsoleTemplate) //Conditional(c => AllowMessage(c), wt => wt. + .WriteTo.Console(outputTemplate: ConsoleTemplate) .CreateLogger(); }); - private static readonly HashSet MessageBuffer = []; - private static bool AllowMessage(LogEvent e) - { - if (e.Level == LogEventLevel.Warning && MessageBuffer.Contains(e.MessageTemplate.Text)) - { - Log.Debug($"Suppressing duplicate message: {e.MessageTemplate.Text.Replace("warning","dupwarn")}"); - return false; - } - MessageBuffer.Add(e.MessageTemplate.Text); - return true; - } - Target Compile => _ => _ .DependsOn(CompileDalamud) .DependsOn(CompileDalamudBoot) @@ -201,7 +188,7 @@ private static bool AllowMessage(LogEvent e) DotNetTasks.DotNetTest(s => s .SetProjectFile(TestProjectFile) .SetConfiguration(Configuration) - .SetNoBuild(true) + .AddProperty("WarningLevel", "0") .EnableNoRestore()); }); From 035f4aa7fdf24d0776494039d8c2fb91a6cc92e8 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Tue, 24 Dec 2024 13:35:31 -0500 Subject: [PATCH 30/32] Reverted previous change to `main.yml`. --- .github/workflows/main.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 710bca992..09e99b84f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,6 @@ name: Build Dalamud -on: - push: - pull_request: - types: [opened] - workflow_dispatch: +on: [push, pull_request, workflow_dispatch] + concurrency: group: build_dalamud_${{ github.ref_name }} cancel-in-progress: true From 005496d8757bc00ab03dd0980faecfd3980502c7 Mon Sep 17 00:00:00 2001 From: Nathan C Date: Fri, 3 Jan 2025 14:24:14 -0500 Subject: [PATCH 31/32] Add conditional for CI builds, add --skip-tests to make up for the combined build/test step. --- .nuke/build.schema.json | 8 ++++++-- build/DalamudBuild.cs | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 0dcc7c47a..58ec446c5 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -88,11 +88,15 @@ "CompileInjector", "CompileInjectorBoot", "Restore", - "SetCustomLogging", + "SetCILogging", "Test" ] } }, + "SkipTests": { + "type": "boolean", + "description": "Whether we should skip tests - useful for local builds" + }, "Solution": { "type": "string", "description": "Path to a solution file that is automatically loaded" @@ -115,7 +119,7 @@ "CompileInjector", "CompileInjectorBoot", "Restore", - "SetCustomLogging", + "SetCILogging", "Test" ] } diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index f591aae64..83b815eb7 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.IO; using Nuke.Common; @@ -27,6 +28,9 @@ public class DalamudBuild : NukeBuild [Parameter("Whether we are building for documentation - emits generated files")] readonly bool IsDocsBuild = false; + [Parameter("Whether we should skip tests - useful for local builds")] + readonly bool SkipTests = false; + [Solution] Solution Solution; [GitRepository] GitRepository GitRepository; @@ -63,6 +67,7 @@ public class DalamudBuild : NukeBuild private static Dictionary EnvironmentVariables => new(EnvironmentInfo.Variables); private static string ConsoleTemplate => "{Message:l}{NewLine}{Exception}"; + private static bool IsCIBuild => Environment.GetEnvironmentVariable("CI") == "true"; Target Restore => _ => _ .Executes(() => @@ -113,8 +118,7 @@ public class DalamudBuild : NukeBuild s = s .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) - .EnableNoRestore() - .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")); + .EnableNoRestore(); // We need to emit compiler generated files for the docs build, since docfx can't run generators directly // TODO: This fails every build after this because of redefinitions... @@ -124,6 +128,11 @@ public class DalamudBuild : NukeBuild s = s .SetProperty("IsDocsBuild", "true"); } + if (IsCIBuild) + { + s = s + .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")); // Disable MSBuild summary on CI builds + } return s; }); @@ -163,8 +172,9 @@ public class DalamudBuild : NukeBuild .SetConfiguration(Configuration)); }); - Target SetCustomLogging => _ => _ + Target SetCILogging => _ => _ .DependentFor(Compile) + .OnlyWhenStatic(() => IsCIBuild) .Executes(() => { Log.Logger = new LoggerConfiguration() @@ -183,6 +193,7 @@ public class DalamudBuild : NukeBuild Target Test => _ => _ .TriggeredBy(Compile) + .OnlyWhenStatic(() => !SkipTests) .Executes(() => { DotNetTasks.DotNetTest(s => s From 2eb52a2966ec49cbec23c43abbb4ab746883d22a Mon Sep 17 00:00:00 2001 From: Nathan C Date: Fri, 3 Jan 2025 17:16:54 -0500 Subject: [PATCH 32/32] Behavior change, now requires arg `ci` to be passed to trigger tests. Tests can also be manually triggered with `test`. --- .github/workflows/main.yml | 22 +++++++++++----------- .nuke/build.schema.json | 6 ++---- build/DalamudBuild.cs | 10 +++++----- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09e99b84f..f1267baca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: ($env:BRANCH) >> VERSION ($env:COMMIT) >> VERSION - name: Build and Test Dalamud - run: .\build.ps1 compile + run: .\build.ps1 ci - name: Sign Dalamud if: ${{ github.repository_owner == 'goatcorp' && github.event_name == 'push' }} env: @@ -86,9 +86,9 @@ jobs: - name: "Verify Compatibility" run: | $FILES_TO_VALIDATE = "Dalamud.dll","FFXIVClientStructs.dll","Lumina.dll","Lumina.Excel.dll" - + $retcode = 0 - + foreach ($file in $FILES_TO_VALIDATE) { $testout = "" Write-Output "::group::=== API COMPATIBILITY CHECK: ${file} ===" @@ -99,7 +99,7 @@ jobs: $retcode = 1 } } - + exit $retcode deploy_stg: @@ -128,18 +128,18 @@ jobs: GH_BRANCH: ${{ steps.extract_branch.outputs.branch }} run: | Compress-Archive .\scratch\* .\canary.zip # Recreate the release zip - + $branchName = $env:GH_BRANCH - + if ($branchName -eq "master") { $branchName = "stg" } - + $newVersion = [System.IO.File]::ReadAllText("$(Get-Location)\scratch\TEMP_gitver.txt") $revision = [System.IO.File]::ReadAllText("$(Get-Location)\scratch\revision.txt") $commitHash = [System.IO.File]::ReadAllText("$(Get-Location)\scratch\commit_hash.txt") Remove-Item -Force -Recurse .\scratch - + if (Test-Path -Path $branchName) { $versionData = Get-Content ".\${branchName}\version" | ConvertFrom-Json $oldVersion = $versionData.AssemblyVersion @@ -158,7 +158,7 @@ jobs: Write-Host "Deployment folder doesn't exist. Not doing anything." Remove-Item .\canary.zip } - + - name: Commit changes shell: bash env: @@ -166,8 +166,8 @@ jobs: run: | git config --global user.name "Actions User" git config --global user.email "actions@github.com" - + git add . git commit -m "[CI] Update staging for ${DVER} on ${GH_BRANCH}" || true - + git push origin main || true diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 58ec446c5..8331affcc 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -76,6 +76,7 @@ "items": { "type": "string", "enum": [ + "CI", "Clean", "Compile", "CompileCImGui", @@ -93,10 +94,6 @@ ] } }, - "SkipTests": { - "type": "boolean", - "description": "Whether we should skip tests - useful for local builds" - }, "Solution": { "type": "string", "description": "Path to a solution file that is automatically loaded" @@ -107,6 +104,7 @@ "items": { "type": "string", "enum": [ + "CI", "Clean", "Compile", "CompileCImGui", diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 83b815eb7..9f647ed7f 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -28,9 +28,6 @@ public class DalamudBuild : NukeBuild [Parameter("Whether we are building for documentation - emits generated files")] readonly bool IsDocsBuild = false; - [Parameter("Whether we should skip tests - useful for local builds")] - readonly bool SkipTests = false; - [Solution] Solution Solution; [GitRepository] GitRepository GitRepository; @@ -191,9 +188,12 @@ public class DalamudBuild : NukeBuild .DependsOn(CompileInjectorBoot) ; + Target CI => _ => _ + .DependsOn(Compile) + .Triggers(Test); + Target Test => _ => _ - .TriggeredBy(Compile) - .OnlyWhenStatic(() => !SkipTests) + .DependsOn(Compile) .Executes(() => { DotNetTasks.DotNetTest(s => s