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

(#219) Add support for new codecov uploader #243

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
AZURE_PASSWORD: ${{ secrets.AZURE_PASSWORD }}
AZURE_SOURCE: ${{ secrets.AZURE_SOURCE }}
AZURE_USER: ${{ secrets.AZURE_USER }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITTER_ROOM_ID: ${{ secrets.GITTER_ROOM_ID }}
GITTER_TOKEN: ${{ secrets.GITTER_TOKEN }}
Expand Down
10 changes: 10 additions & 0 deletions .jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"absolute": true,
"ignore": [
"Source/*.Tests/**"
],
"reporters": [
"consoleFull"
],
"threshold": 0.1
}
180 changes: 164 additions & 16 deletions Source/Cake.Codecov.Tests/CodecovRunnerTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System.Runtime.InteropServices;
using Cake.Codecov.Internals;
using Cake.Codecov.Tests.Attributes;
using Cake.Core;
using Cake.Testing;
using FluentAssertions;
using Moq;
using System;
using Xunit;

namespace Cake.Codecov.Tests
Expand Down Expand Up @@ -107,6 +108,7 @@ public void Should_Find_Codecov_Runner_If_Tool_Path_Not_Provided_On_Windows()

[Theory]
[InlineData("linux-x64/codecov")]
[InlineData("codecov-linux")]
[InlineData("codecov")]
public void Should_Find_Codecov_Runner_If_Tool_Path_Not_Provided_On_Linux(string path)
{
Expand All @@ -129,6 +131,7 @@ public void Should_Find_Codecov_Runner_If_Tool_Path_Not_Provided_On_Linux(string

[Theory]
[InlineData("linux-x64/codecov")]
[InlineData("codecov-macos")]
[InlineData("codecov")]
public void Should_Find_Codecov_Runner_If_Tool_Path_Not_Provided_On_osx(string path)
{
Expand Down Expand Up @@ -216,6 +219,32 @@ public void Should_Set_Build()
result.Args.Should().Be(@"--build ""1""");
}

[Fact]
public void Should_EnableClean()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { CleanReports = true } };

// When
var result = fixture.Run();

// Then
result.Args.Should().Be(@"--clean");
}

[Fact]
public void Should_Not_Enable_Clean()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { CleanReports = false } };

// When
var result = fixture.Run();

// Then
result.Args.Should().BeNullOrEmpty();
}

[Fact]
public void Should_Set_Commit()
{
Expand All @@ -229,8 +258,8 @@ public void Should_Set_Commit()
result.Args.Should().Be(@"--sha ""603e02d40093d0649cfa787d846ae4ccc038085c""");
}

[Fact]
public void Should_Enable_DisableNetwork()
[Fact, Obsolete("Remove test in v2.0.0")]
public void Should_Enable_DryRun_When_DisableNetwork_Is_Set()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { DisableNetwork = true } };
Expand All @@ -239,11 +268,11 @@ public void Should_Enable_DisableNetwork()
var result = fixture.Run();

// Then
result.Args.Should().Be("--disable-network");
result.Args.Should().Be("--dryRun");
}

[Fact]
public void Should_Enable_Dump()
[Fact, Obsolete("Remove test in v2.0.0")]
public void Should_Enable_DryRun_When_Dump_Is_Set()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { Dump = true } };
Expand All @@ -252,7 +281,20 @@ public void Should_Enable_Dump()
var result = fixture.Run();

// Then
result.Args.Should().Be("--dump");
result.Args.Should().Be("--dryRun");
}

[Fact]
public void Should_Enable_DryRun()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { DryRun = true } };

// When
var result = fixture.Run();

// Then
result.Args.Should().Be("--dryRun");
}

[Fact]
Expand Down Expand Up @@ -307,6 +349,32 @@ public void Should_Set_Flags()
result.Args.Should().Be(@"--flag ""ut,chrome""");
}

[Fact]
public void Should_Enable_GCov()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { EnableGcovSupport = true } };

// When
var result = fixture.Run();

// Then
result.Args.Should().Be(@"--gcov");
}

[Fact]
public void Should_Not_Enable_GCov()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { EnableGcovSupport = false } };

// When
var result = fixture.Run();

// Then
result.Args.Should().BeNullOrEmpty();
}

[Fact]
public void Should_Set_Name()
{
Expand All @@ -316,12 +384,12 @@ public void Should_Set_Name()
// When
var result = fixture.Run();

// Then
// ThenRæ
result.Args.Should().Be(@"--name ""custom name""");
}

[Fact]
public void Should_Enable_NoColor()
[Fact, Obsolete("Remove test in v2.0.0")]
public void Should_Ignore_NoColor()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { NoColor = true } };
Expand All @@ -330,7 +398,7 @@ public void Should_Enable_NoColor()
var result = fixture.Run();

// Then
result.Args.Should().Be("--no-color");
result.Args.Should().BeNullOrEmpty();
}

[Fact]
Expand All @@ -346,8 +414,8 @@ public void Should_Set_Pr()
result.Args.Should().Be(@"--pr ""1""");
}

[Fact]
public void Should_Enable_Required()
[Fact, Obsolete("Remove in v2.0.0")]
public void Should_Enable_NonZero_When_Required_Is_Set()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { Required = true } };
Expand All @@ -356,11 +424,37 @@ public void Should_Enable_Required()
var result = fixture.Run();

// Then
result.Args.Should().Be("--required");
result.Args.Should().Be("--nonZero");
}

[Fact]
public void Should_Set_Root()
public void Should_Enable_NonZero()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { NonZero = true } };

// When
var result = fixture.Run();

// Then
result.Args.Should().Be("--nonZero");
}

[Fact]
public void Should_Sete_ParentSha()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { ParentSha = "some-kind-of-sha" } };

// When
var result = fixture.Run();

// Then
result.Args.Should().Be(@"--parent ""some-kind-of-sha""");
}

[Fact, Obsolete("Remove test in v2.0.0")]
public void Should_Set_RootDirectory_When_Root_Is_Set()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { Root = @".\working" } };
Expand All @@ -369,7 +463,35 @@ public void Should_Set_Root()
var result = fixture.Run();

// Then
result.Args.Should().Be(@"--root ""working""");
result.Args.Should().Be(@"--rootDir ""working""");
}

[Fact]
public void Should_Set_RootDirectory()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { RootDirectory = @".\working" } };

// When
var result = fixture.Run();

// Then
result.Args.Should().Be(@"--rootDir ""working""");
}

[Fact]
public void Should_Set_SearchDirectory()
{
var directory = Environment.CurrentDirectory.Replace("\\", "/");

// Given
var fixture = new CodecovRunnerFixture { Settings = { SearchDirectory = Environment.CurrentDirectory } };

// When
var result = fixture.Run();

// Then
result.Args.Should().Be(@$"--dir ""{directory}""");
}

[Fact]
Expand All @@ -385,6 +507,32 @@ public void Should_Set_Slug()
result.Args.Should().Be(@"--slug ""owner/repo""");
}

[Fact]
public void Should_Enable_Changelog()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { ShowChangelog = true } };

// When
var result = fixture.Run();

// Then
result.Args.Should().Be("--changelog");
}

[Fact]
public void Should_Not_Enable_Changelog()
{
// Given
var fixture = new CodecovRunnerFixture { Settings = { ShowChangelog = false } };

// When
var result = fixture.Run();

// Then
result.Args.Should().BeNullOrEmpty();
}

[Fact]
public void Should_Set_Tag()
{
Expand Down