diff --git a/.gitignore b/.gitignore
index efc3a76e7c..aaf4127eae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -101,4 +101,5 @@ Backup/
.dotnet/*
tools/*
!tools/gitversion_wrapper.sh
-!tools/LINQPad
\ No newline at end of file
+!tools/LINQPad
+coverage-results/*
\ No newline at end of file
diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj
index 3833185d95..ed8ebc2884 100644
--- a/Octokit.Reactive/Octokit.Reactive.csproj
+++ b/Octokit.Reactive/Octokit.Reactive.csproj
@@ -12,7 +12,7 @@
1.6.0
Octokit.Reactive
Octokit.Reactive
- embedded
+ portable
https://github.com/octokit/octokit.net
https://github.com/octokit/octokit.net
https://f.cloud.github.com/assets/19977/1510987/64af2b26-4a9d-11e3-89fc-96a185171c75.png
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index 8d8e5df184..261a405b3d 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -12,7 +12,7 @@
1.6.0
Octokit
Octokit
- embedded
+ portable
https://github.com/octokit/octokit.net
https://github.com/octokit/octokit.net
https://f.cloud.github.com/assets/19977/1510987/64af2b26-4a9d-11e3-89fc-96a185171c75.png
diff --git a/README.md b/README.md
index c73c0c58fd..04089d46d3 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
[![Build status](https://ci.appveyor.com/api/projects/status/cego2g42yw26th26/branch/master?svg=true)](https://ci.appveyor.com/project/github-windows/octokit-net/branch/master)
[![Build Status]( https://travis-ci.org/octokit/octokit.net.svg)]( https://travis-ci.org/octokit/octokit.net)
+[![codecov](https://codecov.io/gh/octokit/octokit.net/branch/master/graph/badge.svg)](https://codecov.io/gh/octokit/octokit.net)
[![Join the chat at https://gitter.im/octokit/octokit.net](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/octokit/octokit.net?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![NuGet](http://img.shields.io/nuget/v/Octokit.svg)](https://www.nuget.org/packages/Octokit)
[![NuGet](http://img.shields.io/nuget/v/Octokit.Reactive.svg)](https://www.nuget.org/packages/Octokit.Reactive)
diff --git a/appveyor.yml b/appveyor.yml
index 6d09d6be6b..be9bafff9e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -9,6 +9,7 @@ init:
build_script:
- dotnet --info
+ - dotnet tool install --global coverlet.console
- ps: .\build.ps1 -LinkSources -Verbosity Verbose
test: off
diff --git a/build/Build.csproj b/build/Build.csproj
index 9583f95e6c..ba936c2b8c 100644
--- a/build/Build.csproj
+++ b/build/Build.csproj
@@ -6,7 +6,10 @@
+
+
+
diff --git a/build/Context.cs b/build/Context.cs
index ad77c00ba1..f0d93e199a 100644
--- a/build/Context.cs
+++ b/build/Context.cs
@@ -13,6 +13,7 @@ public class Context : FrostingContext
public BuildVersion Version { get; set; }
public DirectoryPath Artifacts { get; set; }
+ public DirectoryPath CodeCoverage { get; set; }
public bool IsLocalBuild { get; set; }
public bool IsPullRequest { get; set; }
diff --git a/build/Lifetime.cs b/build/Lifetime.cs
index fb292c8f6c..47029d71ac 100644
--- a/build/Lifetime.cs
+++ b/build/Lifetime.cs
@@ -15,6 +15,7 @@ public override void Setup(Context context)
context.CoreOnly = context.Argument("CoreOnly", !context.IsRunningOnWindows());
context.Artifacts = "./packaging/";
+ context.CodeCoverage = "./coverage-results/";
// Build system information.
var buildSystem = context.BuildSystem();
diff --git a/build/Tasks/Clean.cs b/build/Tasks/Clean.cs
index 478bccdc40..f0a82f1473 100644
--- a/build/Tasks/Clean.cs
+++ b/build/Tasks/Clean.cs
@@ -13,7 +13,8 @@ public override void Run(Context context)
var directories = context.GetDirectories("./**/bin", globberSettings)
+ context.GetDirectories("./**/obj", globberSettings)
- + context.Artifacts;
+ + context.Artifacts
+ + context.CodeCoverage;
foreach (var directory in directories)
{
diff --git a/build/Tasks/CodeCoverage.cs b/build/Tasks/CodeCoverage.cs
new file mode 100644
index 0000000000..fcec4c98ba
--- /dev/null
+++ b/build/Tasks/CodeCoverage.cs
@@ -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
+{
+ public override void Run(Context context)
+ {
+ var coverageFiles = new List();
+
+ 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()
+ {
+ { "APPVEYOR_BUILD_VERSION", buildVersion}
+ }
+ };
+
+ context.Codecov(settings);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/build/Tasks/Package.cs b/build/Tasks/Package.cs
index f3b362cfa2..6673708e76 100644
--- a/build/Tasks/Package.cs
+++ b/build/Tasks/Package.cs
@@ -6,6 +6,7 @@
[Dependency(typeof(UnitTests))]
[Dependency(typeof(ConventionTests))]
+[Dependency(typeof(CodeCoverage))]
[Dependency(typeof(ValidateLINQPadSamples))]
public sealed class Package : FrostingTask
{
diff --git a/build/Tools/Coverlet.cs b/build/Tools/Coverlet.cs
new file mode 100644
index 0000000000..8b94f29713
--- /dev/null
+++ b/build/Tools/Coverlet.cs
@@ -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
+{
+ 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 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);
+ }
+}
\ No newline at end of file
diff --git a/build/Utilities/BuildVersion.cs b/build/Utilities/BuildVersion.cs
index f178507845..7c4985981c 100644
--- a/build/Utilities/BuildVersion.cs
+++ b/build/Utilities/BuildVersion.cs
@@ -6,11 +6,13 @@ public class BuildVersion
{
public string Prefix { get; set; }
public string Suffix { get; set; }
+ public string FullSemVer { get; set; }
- public BuildVersion(string version, string suffix)
+ public BuildVersion(string version, string suffix, string fullSemVer)
{
Prefix = version;
Suffix = suffix;
+ FullSemVer = fullSemVer;
if (string.IsNullOrWhiteSpace(Suffix))
{
@@ -29,6 +31,10 @@ public string GetSemanticVersion()
public static BuildVersion Calculate(Context context)
{
+ string version = null;
+ string semVersion = null;
+ string fullSemVer = null;
+
context.Information("Calculating semantic version...");
if (!context.IsLocalBuild)
@@ -40,14 +46,15 @@ public static BuildVersion Calculate(Context context)
// Run in interactive mode to get the properties for the rest of the script
var assertedversions = GitVersionRunner.Run(context, GitVersionOutput.Json);
- var version = assertedversions.MajorMinorPatch;
- var semVersion = assertedversions.LegacySemVerPadded;
+ version = assertedversions.MajorMinorPatch;
+ semVersion = assertedversions.LegacySemVerPadded;
+ fullSemVer = assertedversions.FullSemVer;
if (string.IsNullOrWhiteSpace(version))
{
throw new CakeException("Could not calculate version of build.");
}
- return new BuildVersion(version, semVersion.Substring(version.Length).TrimStart('-'));
+ return new BuildVersion(version, semVersion.Substring(version.Length).TrimStart('-'), fullSemVer);
}
}
\ No newline at end of file
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 0000000000..6d84812d82
--- /dev/null
+++ b/codecov.yml
@@ -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/::"