diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 930adf8ed..f1267baca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,6 @@ name: Build Dalamud on: [push, pull_request, workflow_dispatch] + concurrency: group: build_dalamud_${{ github.ref_name }} cancel-in-progress: true @@ -32,10 +33,8 @@ jobs: ($env:REPO_NAME) >> VERSION ($env:BRANCH) >> VERSION ($env:COMMIT) >> VERSION - - name: Build Dalamud - run: .\build.ps1 compile - - name: Test Dalamud - run: .\build.ps1 test + - name: Build and Test Dalamud + run: .\build.ps1 ci - name: Sign Dalamud if: ${{ github.repository_owner == 'goatcorp' && github.event_name == 'push' }} env: @@ -87,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} ===" @@ -100,7 +99,7 @@ jobs: $retcode = 1 } } - + exit $retcode deploy_stg: @@ -129,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 @@ -159,7 +158,7 @@ jobs: Write-Host "Deployment folder doesn't exist. Not doing anything." Remove-Item .\canary.zip } - + - name: Commit changes shell: bash env: @@ -167,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 e7e1a446a..8331affcc 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -76,6 +76,7 @@ "items": { "type": "string", "enum": [ + "CI", "Clean", "Compile", "CompileCImGui", @@ -88,6 +89,7 @@ "CompileInjector", "CompileInjectorBoot", "Restore", + "SetCILogging", "Test" ] } @@ -102,6 +104,7 @@ "items": { "type": "string", "enum": [ + "CI", "Clean", "Compile", "CompileCImGui", @@ -114,6 +117,7 @@ "CompileInjector", "CompileInjectorBoot", "Restore", + "SetCILogging", "Test" ] } diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index 67a812916..d374c79f8 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; @@ -5,6 +6,7 @@ using Nuke.Common.Execution; 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; @@ -61,6 +63,9 @@ 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(() => { @@ -123,16 +128,20 @@ public class DalamudBuild : NukeBuild .SetProjectFile(DalamudProjectFile) .SetConfiguration(Configuration) .EnableNoRestore(); - + if (IsCIBuild) + { + s = s + .SetProcessArgumentConfigurator(a => a.Add("/clp:NoSummary")); // Disable MSBuild summary on CI builds + } // 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... + // if (IsDocsBuild) // { // Log.Warning("Building for documentation, emitting compiler generated files. This can cause issues on Windows due to path-length limitations"); // s = s // .SetProperty("IsDocsBuild", "true"); // } - return s; }); }); @@ -171,12 +180,28 @@ public class DalamudBuild : NukeBuild .SetConfiguration(Configuration)); }); + Target SetCILogging => _ => _ + .DependentFor(Compile) + .OnlyWhenStatic(() => IsCIBuild) + .Executes(() => + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.Console(outputTemplate: ConsoleTemplate) + .CreateLogger(); + }); + Target Compile => _ => _ - .DependsOn(CompileDalamud) - .DependsOn(CompileDalamudBoot) - .DependsOn(CompileDalamudCrashHandler) - .DependsOn(CompileInjector) - .DependsOn(CompileInjectorBoot); + .DependsOn(CompileDalamud) + .DependsOn(CompileDalamudBoot) + .DependsOn(CompileDalamudCrashHandler) + .DependsOn(CompileInjector) + .DependsOn(CompileInjectorBoot) + ; + + Target CI => _ => _ + .DependsOn(Compile) + .Triggers(Test); Target Test => _ => _ .DependsOn(Compile) @@ -185,6 +210,7 @@ public class DalamudBuild : NukeBuild DotNetTasks.DotNetTest(s => s .SetProjectFile(TestProjectFile) .SetConfiguration(Configuration) + .AddProperty("WarningLevel", "0") .EnableNoRestore()); });