Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run full build on GitHub Actions #645

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
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
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions recipe.cake
Original file line number Diff line number Diff line change
@@ -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

//*************************************************************************************************
Expand All @@ -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"
);
Expand Down Expand Up @@ -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<BuildVersion>((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<string, string> { { "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
Expand Down
Loading