Skip to content

Commit

Permalink
fix(tools): tool path for CodecovTasks (#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
gtbuchanan authored Jul 9, 2024
1 parent ac38220 commit 6446551
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion source/Nuke.Common/Tools/Codecov/Codecov.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "Codecov",
"officialUrl": "https://about.codecov.io/",
"help": "Code coverage is a measurement used to express which lines of code were executed by a test suite. We use three primary terms to describe each line executed.<para/><ul><li>hit - indicates that the source code was executed by the test suite.</li><li>partial - indicates that the source code was not fully executed by the test suite; there are remaining branches that were not executed.</li><li>miss - indicates that the source code was not executed by the test suite.</li></ul><para/>Coverage is the ratio of <c>hits / (sum of hit + partial + miss)</c>. A code base that has 5 lines executed by tests out of 12 total lines will receive a coverage ratio of 41% (rounding down).<para/>Phrased simply, code coverage provides a visual measurement of what source code is being executed by a test suite. This information indicates to the software developer where they should write new tests in an effort to achieve higher coverage.<para/>Testing source code helps to prevent bugs and syntax errors by executing each line with a known variable and cross-checking it with an expected output.",
"nugetPackageId": "Codecov.Tool",
"nugetPackageId": "CodecovUploader",
"customExecutable": true,
"tasks": [
{
Expand Down
21 changes: 16 additions & 5 deletions source/Nuke.Common/Tools/Codecov/CodecovTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System;
using Nuke.Common.Tooling;

namespace Nuke.Common.Tools.Codecov;
Expand All @@ -10,17 +11,27 @@ partial class CodecovSettings
{
private string GetProcessToolPath()
{
return CodecovTasks.GetToolPath(Framework);
return CodecovTasks.GetToolPath();
}
}

partial class CodecovTasks
{
internal static string GetToolPath(string framework = null)
internal static string GetToolPath()
{
return NuGetToolPathResolver.GetPackageExecutable(
packageId: "Codecov.Tool",
packageExecutable: "codecov.dll",
framework: framework);
packageId: "CodecovUploader",
packageExecutable: GetPackageExecutable());
}

private static string GetPackageExecutable()
{
return EnvironmentInfo.Platform switch
{
PlatformFamily.Windows => "codecov.exe",
PlatformFamily.OSX => "codecov-macos",
PlatformFamily.Linux => "codecov-linux",
_ => throw new ArgumentOutOfRangeException()
};
}
}

0 comments on commit 6446551

Please sign in to comment.