-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for Codecov reporting on Windows
Co-Authored-By: Stanley Goldman <[email protected]>
- Loading branch information
1 parent
1f01b22
commit 7837fe5
Showing
14 changed files
with
191 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,4 +101,5 @@ Backup/ | |
.dotnet/* | ||
tools/* | ||
!tools/gitversion_wrapper.sh | ||
!tools/LINQPad | ||
!tools/LINQPad | ||
coverage-results/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
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 + "-netcoreapp2.0.xml"); | ||
coverageFiles.Add(dotNetCoreCoverage); | ||
|
||
context.Coverlet(project, new CoverletToolSettings() | ||
{ | ||
Configuration = context.Configuration, | ||
Framework = "netcoreapp2.0", | ||
Output = dotNetCoreCoverage.FullPath | ||
}); | ||
|
||
if (context.IsRunningOnWindows()) | ||
{ | ||
var dotNetFrameworkCoverage = context.CodeCoverage | ||
.CombineWithFilePath(project.Name + "-net452.xml"); | ||
coverageFiles.Add(dotNetFrameworkCoverage); | ||
|
||
context.Coverlet(project, new CoverletToolSettings | ||
{ | ||
Configuration = context.Configuration, | ||
Framework = "net452", | ||
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.1.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); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Cake.Common.Diagnostics; | ||
using Cake.Core; | ||
using Cake.Core.Annotations; | ||
using Cake.Core.IO; | ||
using Cake.Core.Tooling; | ||
|
||
public class CoverletTool : Tool<CoverletToolSettings> | ||
{ | ||
private readonly ICakeEnvironment _environment; | ||
|
||
public CoverletTool(IFileSystem fileSystem, ICakeEnvironment environment, IProcessRunner runner, IToolLocator tools) | ||
: base(fileSystem, environment, runner, tools) | ||
{ | ||
_environment = environment; | ||
} | ||
|
||
public void Coverlet(Project project, CoverletToolSettings settings) | ||
{ | ||
var arguments = new ProcessArgumentBuilder(); | ||
|
||
var filePath = FilePath.FromString($"bin\\{settings.Configuration}\\{settings.Framework}\\{project.Name}.dll"); | ||
var fullPath = project.Path.GetDirectory().CombineWithFilePath(filePath).MakeAbsolute(_environment); | ||
|
||
arguments.Append($"\"{fullPath}\" --target \"dotnet\" --targetargs \"test -c {settings.Configuration} {project.Path.FullPath} --no-build\" --format opencover --output \"{settings.Output}\""); | ||
|
||
Run(settings, arguments); | ||
} | ||
|
||
protected override string GetToolName() | ||
{ | ||
return "Coverlet"; | ||
} | ||
|
||
protected override IEnumerable<string> GetToolExecutableNames() | ||
{ | ||
return new[] { "coverlet", "coverlet.exe" }; | ||
} | ||
} | ||
|
||
public class CoverletToolSettings : ToolSettings | ||
{ | ||
public string Configuration { get; set; } | ||
public string Framework { get; set; } | ||
public string Output { get; set; } | ||
} | ||
|
||
public static class CoverletAliases | ||
{ | ||
[CakeMethodAlias] | ||
public static void Coverlet(this ICakeContext context, Project project, CoverletToolSettings settings = null) | ||
{ | ||
if (context == null) | ||
throw new ArgumentNullException(nameof(context)); | ||
|
||
if (settings == null) | ||
throw new ArgumentNullException(nameof(settings)); | ||
|
||
new CoverletTool(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools).Coverlet(project, settings); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
codecov: | ||
notify: | ||
require_ci_to_pass: yes | ||
|
||
coverage: | ||
precision: 2 | ||
round: down | ||
range: "70...100" | ||
|
||
status: | ||
project: yes | ||
patch: yes | ||
changes: no | ||
|
||
parsers: | ||
gcov: | ||
branch_detection: | ||
conditional: yes | ||
loop: yes | ||
method: no | ||
macro: no | ||
|
||
comment: | ||
layout: "header, diff, files" | ||
behavior: once | ||
require_changes: no | ||
|
||
fixes: | ||
- "/C/projects/octokit-net/::" |