|
1 | 1 | using GlobExpressions; |
2 | 2 | using Nuke.Common; |
3 | 3 | using Nuke.Common.CI; |
| 4 | +using Nuke.Common.CI.GitHubActions; |
4 | 5 | using Nuke.Common.Git; |
5 | 6 | using Nuke.Common.IO; |
6 | 7 | using Nuke.Common.ProjectModel; |
@@ -46,8 +47,6 @@ class Build : NukeBuild |
46 | 47 | AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; |
47 | 48 | AbsolutePath NugetDirectory => ArtifactsDirectory / "nuget"; |
48 | 49 | AbsolutePath TestResultDirectory => ArtifactsDirectory / "test-results"; |
49 | | - AbsolutePath CoverageResultDirectory => ArtifactsDirectory / "coverage"; |
50 | | - AbsolutePath CoverageReportDirectory => ArtifactsDirectory / "coverage-report"; |
51 | 50 |
|
52 | 51 | IEnumerable<Project> TestProjects => Solution.GetAllProjects("*.Tests"); |
53 | 52 |
|
@@ -95,28 +94,15 @@ class Build : NukeBuild |
95 | 94 | .EnableNoBuild() |
96 | 95 | .ResetVerbosity() |
97 | 96 | .SetResultsDirectory(TestResultDirectory) |
98 | | - .EnableCollectCoverage() |
99 | | - .SetCoverletOutputFormat(CoverletOutputFormat.cobertura) |
100 | | - .SetExcludeByFile("*.Generated.cs") |
101 | | - .CombineWith(TestProjects, (_, v) => _ |
102 | | - .SetProjectFile(v) |
103 | | - .SetLoggers($"trx;LogFileName={v.Name}.trx;FailureBodyFormat=Verbose") |
104 | | - .SetCoverletOutput($"{CoverageResultDirectory}/{v.Name}.xml")))); |
105 | | - |
106 | | - Target Cover => _ => _ |
107 | | - .DependsOn(Test) |
108 | | - .Consumes(Test) |
109 | | - .Produces(CoverageResultDirectory / "lcov.info") |
110 | | - .Executes(() => |
111 | | - { |
112 | | - ReportGenerator(_ => _ |
113 | | - .SetFramework("net5.0") |
114 | | - .SetReports(CoverageResultDirectory / "*.xml") |
115 | | - .SetTargetDirectory(CoverageReportDirectory) |
116 | | - .SetReportTypes("lcov") |
117 | | - .When(IsLocalBuild, _ => _ |
118 | | - .AddReportTypes(ReportTypes.HtmlInline))); |
119 | | - }); |
| 97 | + .CombineWith(TestProjects, (_, project) => _ |
| 98 | + .SetProjectFile(project) |
| 99 | + .When(GitHubActions.Instance is not null && project.HasPackageReference("GitHubActionsTestLogger"), |
| 100 | + settings => settings.AddLoggers("GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true") |
| 101 | + .AddRunSetting("RunConfiguration.CollectSourceInformation", "true")) |
| 102 | + .AddLoggers($"trx;LogFileName={project.Name}.trx;FailureBodyFormat=Verbose") |
| 103 | + .When(project.HasPackageReference("coverlet.collector"), |
| 104 | + settings => settings.SetDataCollector("XPlat Code Coverage") |
| 105 | + .SetSettingsFile("coverlet.runsettings"))))); |
120 | 106 |
|
121 | 107 | Target Pack => _ => _ |
122 | 108 | .DependsOn(Clean, Restore) |
|
0 commit comments