Skip to content

Commit

Permalink
Move coveralls step to NUKE
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-VBFK committed Jan 11, 2023
1 parent 1725cc0 commit 726319d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/build.yml
Expand Up @@ -28,12 +28,7 @@ jobs:
run: ./build.ps1
env:
ApiKey: ${{ secrets.NUGETAPIKEY }}

- name: coveralls
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: TestResults/reports/lcov.info
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
5 changes: 5 additions & 0 deletions .nuke/build.schema.json
Expand Up @@ -14,6 +14,9 @@
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
"GithubToken": {
"type": "string"
},
"Help": {
"type": "boolean",
"description": "Shows the help text for this build assembly"
Expand Down Expand Up @@ -73,6 +76,7 @@
"Clean",
"CodeCoverage",
"Compile",
"Coveralls",
"Pack",
"Push",
"Restore",
Expand All @@ -97,6 +101,7 @@
"Clean",
"CodeCoverage",
"Compile",
"Coveralls",
"Pack",
"Push",
"Restore",
Expand Down
38 changes: 29 additions & 9 deletions Build/Build.cs
Expand Up @@ -9,12 +9,14 @@
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.CoverallsNet;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Tools.ReportGenerator;
using Nuke.Common.Tools.Xunit;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.CoverallsNet.CoverallsNetTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks;
using static Nuke.Common.Tools.Xunit.XunitTasks;
Expand Down Expand Up @@ -76,6 +78,9 @@ class Build : NukeBuild
.OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)
.Executes(() =>
{
Information(BranchSpec);
Information(BuildNumber);
Information(PullRequestBase);
EnsureCleanDirectory(ArtifactsDirectory);
EnsureCleanDirectory(TestResultsDirectory);
});
Expand Down Expand Up @@ -184,23 +189,35 @@ class Build : NukeBuild
});

Target CodeCoverage => _ => _
.DependsOn(TestFrameworks)
.DependsOn(UnitTests)
.DependsOn(TestFrameworks, UnitTests)
.OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)
.Executes(() =>
{
ReportGenerator(s => s
.SetProcessToolPath(ToolPathResolver.GetPackageExecutable("ReportGenerator", "ReportGenerator.dll", framework: "net6.0"))
.SetTargetDirectory(TestResultsDirectory / "reports")
.AddReports(TestResultsDirectory / "**/coverage.cobertura.xml")
.AddReportTypes("HtmlInline_AzurePipelines_Dark", "lcov")
.AddReportTypes(
ReportTypes.Cobertura,
ReportTypes.lcov,
ReportTypes.HtmlInline_AzurePipelines_Dark)
.AddFileFilters("-*.g.cs")
.SetAssemblyFilters("+FluentAssertions"));
string link = TestResultsDirectory / "reports" / "index.html";
Information($"Code coverage report: \x1b]8;;file://{link.Replace('\\', '/')}\x1b\\{link}\x1b]8;;\x1b\\");
});

Target Coveralls => _ => _
.DependsOn(CodeCoverage)
.OnlyWhenDynamic(() => !IsLocalBuild && (RunAllTargets || HasSourceChanges))
.Executes(() =>
{
CoverallsNet(s => s
.SetInput(TestResultsDirectory / "reports" / "Cobertura.xml")
.EnableDynamicCodeCoverage());
});

Target TestFrameworks => _ => _
.DependsOn(Compile)
.OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)
Expand Down Expand Up @@ -238,12 +255,15 @@ class Build : NukeBuild
});

Target Pack => _ => _
.DependsOn(ApiChecks)
.DependsOn(TestFrameworks)
.DependsOn(UnitTests)
.DependsOn(CodeCoverage)
.DependsOn(CalculateNugetVersion)
.DependsOn(
ApiChecks,
TestFrameworks,
UnitTests,
CodeCoverage,
Coveralls,
CalculateNugetVersion)
.OnlyWhenDynamic(() => RunAllTargets || HasSourceChanges)
.Produces(ArtifactsDirectory / "*.nupkg")
.Executes(() =>
{
DotNetPack(s => s
Expand Down Expand Up @@ -286,7 +306,7 @@ class Build : NukeBuild
});

string YarnCli => $"{ToolPathResolver.GetPackageExecutable("Yarn.MSBuild", "yarn.js", "1.22.19")} --silent";

bool HasDocumentationChanges =>
Changes.Any(x => x.StartsWith("docs", StringComparison.InvariantCultureIgnoreCase));

Expand Down
1 change: 1 addition & 0 deletions Build/_build.csproj
Expand Up @@ -17,6 +17,7 @@
<DefineConstants>OS_MAC</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageDownload Include="coveralls.net" Version="[4.0.1]" />
<PackageDownload Include="GitVersion.Tool" Version="[5.11.1]" />
<PackageDownload Include="NSpec" Version="[3.1.0]" />
<PackageDownload Include="ReportGenerator" Version="[5.1.13]" />
Expand Down

0 comments on commit 726319d

Please sign in to comment.