Files
octokit.net/build/Tasks/CodeCoverage.cs
dependabot-preview[bot] 2b2626be0d Bump System.Reactive from 3.1.0 to 4.3.2 (#2055)
* drop mentions of net45 from core

* Bump System.Reactive from 3.1.0 to 4.3.2

Bumps [System.Reactive](https://github.com/dotnet/reactive) from 3.1.0 to 4.3.2.
- [Release notes](https://github.com/dotnet/reactive/releases)
- [Commits](https://github.com/dotnet/reactive/compare/v3.1.0...rxnet-v4.3.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* upgrade from net452 to net46 in test projects

* drop netstandard1.1 support

* correct this test reference

* add necessary dependency for test project

* add new dependency needed for integration tests

* upload net462 code coverage

* upgrade environment for validating linqpad examples

* bump linqpad to latest 5.x release

Co-authored-by: Brendan Forster <brendan@github.com>
2020-02-10 06:33:41 -04:00

76 lines
2.8 KiB
C#

using System.Collections.Generic;
using System.Linq;
using Cake.Codecov;
using Cake.Common;
using Cake.Common.Build;
using Cake.Common.Diagnostics;
using Cake.Core.IO;
using Cake.Frosting;
[Dependency(typeof(Build))]
public sealed class CodeCoverage : FrostingTask<Context>
{
public override void Run(Context context)
{
var coverageFiles = new List<FilePath>();
if (context.AppVeyor)
{
foreach (var project in context.Projects.Where(x => x.UnitTests))
{
context.Information("Executing Code Coverage for Project {0}...", project.Name);
var dotNetCoreCoverage = context.CodeCoverage
.CombineWithFilePath(project.Name + "-netcoreapp3.1.xml");
coverageFiles.Add(dotNetCoreCoverage);
context.Coverlet(project, new CoverletToolSettings()
{
Configuration = context.Configuration,
Framework = "netcoreapp3.1",
Output = dotNetCoreCoverage.FullPath
});
if (context.IsRunningOnWindows())
{
var dotNetFrameworkCoverage = context.CodeCoverage
.CombineWithFilePath(project.Name + "-net46.xml");
coverageFiles.Add(dotNetFrameworkCoverage);
context.Coverlet(project, new CoverletToolSettings
{
Configuration = context.Configuration,
Framework = "net46",
Output = dotNetFrameworkCoverage.FullPath
});
}
context.Information("Uploading Coverage Files: {0}", string.Join(",", coverageFiles.Select(path => path.GetFilename().ToString())));
var buildVersion = $"{context.Version.FullSemVer}.build.{context.EnvironmentVariable("APPVEYOR_BUILD_NUMBER")}";
var userProfilePath = context.EnvironmentVariable("USERPROFILE");
var codecovPath = new DirectoryPath(userProfilePath)
.CombineWithFilePath(".nuget\\packages\\codecov\\1.10.0\\tools\\codecov.exe");
context.Tools.RegisterFile(codecovPath);
foreach (var coverageFile in coverageFiles)
{
var settings = new CodecovSettings
{
Files = new[] { coverageFile.MakeAbsolute(context.Environment).FullPath },
Verbose = true,
EnvironmentVariables = new Dictionary<string, string>()
{
{ "APPVEYOR_BUILD_VERSION", buildVersion}
}
};
context.Codecov(settings);
}
}
}
}
}