diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..404baaf18 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: Full build + +# Workflow Trigger +on: + # Trigger the workflow on a pull request to any branch + pull_request: + +jobs: + Build: + name: Run full build + runs-on: windows-2022 + steps: + - name: Get the sources + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 + - name: Fetch all tags and branches + run: git fetch --prune --unshallow + - name: Install .NET + uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4 + with: + # .NET 5 required for GitVersion + dotnet-version: | + 5.x + 6.x + 7.x + 8.x + - name: Build + run: ./build.sh --target=ci + shell: bash \ No newline at end of file diff --git a/recipe.cake b/recipe.cake index 1776640be..388b8fe2a 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,3 +1,7 @@ +// Use never version of Cake.Codecov +// Can be removed once https://github.com/cake-contrib/Cake.Recipe/pull/1002 has shipped +#addin nuget:?package=Cake.Codecov&version=1.0.1 + #load nuget:?package=Cake.Recipe&version=3.1.1 //************************************************************************************************* @@ -23,6 +27,9 @@ BuildParameters.SetParameters( BuildParameters.PrintParameters(Context); ToolSettings.SetToolPreprocessorDirectives( + // Use CodecovUploader instead of unofficial Codecov exe. + // Can be removed once https://github.com/cake-contrib/Cake.Recipe/pull/1002 has shipped + codecovGlobalTool: "#tool nuget:?package=CodecovUploader&version=0.7.3", gitReleaseManagerGlobalTool: "#tool dotnet:?package=GitReleaseManager.Tool&version=0.17.0", nugetTool: "#tool nuget:?package=NuGet.CommandLine&version=6.9.1" ); @@ -127,6 +134,43 @@ BuildParameters.Tasks.InspectCodeTask }) ); +// Updated for CodecovUploader +// Can be removed once https://github.com/cake-contrib/Cake.Recipe/pull/1002 has shipped +((CakeTask)BuildParameters.Tasks.UploadCodecovReportTask.Task).Actions.Clear(); +BuildParameters.Tasks.UploadCodecovReportTask + .WithCriteria(() => BuildParameters.IsMainRepository, "Skipping because not running from the main repository") + .WithCriteria(() => BuildParameters.ShouldRunCodecov, "Skipping because uploading to codecov is disabled") + .WithCriteria(() => BuildParameters.CanPublishToCodecov, "Skipping because repo token is missing, or not running on appveyor") + .Does((context, buildVersion) => RequireTool(BuildParameters.IsDotNetCoreBuild ? ToolSettings.CodecovGlobalTool : ToolSettings.CodecovTool, () => { + var coverageFiles = GetFiles(BuildParameters.Paths.Directories.TestCoverage + "/coverlet/*.xml"); + if (FileExists(BuildParameters.Paths.Files.TestCoverageOutputFilePath)) + { + coverageFiles += BuildParameters.Paths.Files.TestCoverageOutputFilePath; + } + + if (coverageFiles.Any()) + { + var settings = new CodecovSettings { + Files = coverageFiles.Select(f => f.FullPath), + Required = true, + Token = BuildParameters.Codecov.RepoToken + }; + if (buildVersion != null && + !string.IsNullOrEmpty(buildVersion.FullSemVersion) && + BuildParameters.IsRunningOnAppVeyor) + { + // Required to work correctly with appveyor because environment changes isn't detected until cake is done running. + var localBuildVersion = string.Format("{0}.build.{1}", + buildVersion.FullSemVersion, + BuildSystem.AppVeyor.Environment.Build.Number); + settings.EnvironmentVariables = new Dictionary { { "APPVEYOR_BUILD_VERSION", localBuildVersion }}; + } + + Codecov(settings); + } + }) +); + // Upload only .NET 8 coverage results to avoid issues with files being too large ((CakeTask)BuildParameters.Tasks.UploadCodecovReportTask.Task).Actions.Clear(); BuildParameters.Tasks.UploadCodecovReportTask