Skip to content

Commit eabfafa

Browse files
Avoid GitHub step summary file write conflicts (#2848)
Refactor coverage report for GitHub step summary to try and resolve file conflict issues (and make the code more readable). Contributes to #2836.
1 parent d6493dd commit eabfafa

6 files changed

Lines changed: 17 additions & 5 deletions

File tree

Directory.Build.targets

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@
1717
<ReportGeneratorReportTypes Condition=" '$(ReportGeneratorOutputMarkdown)' == 'true' ">$(ReportGeneratorReportTypes);MarkdownSummaryGitHub</ReportGeneratorReportTypes>
1818
<ReportGeneratorTargetDirectory>$([System.IO.Path]::Combine($(ArtifactsPath), 'coverage'))</ReportGeneratorTargetDirectory>
1919
<MergeWith>$([System.IO.Path]::Combine($(ReportGeneratorTargetDirectory), 'coverage.json'))</MergeWith>
20-
<_MarkdownSummaryPrefix>&lt;details&gt;&lt;summary&gt;:chart_with_upwards_trend: &lt;b&gt;$(AssemblyName) Code Coverage report&lt;/b&gt;&lt;/summary&gt;</_MarkdownSummaryPrefix>
21-
<_MarkdownSummarySuffix>&lt;/details&gt;</_MarkdownSummarySuffix>
2220
</PropertyGroup>
2321
<Target Name="GenerateCoverageReports" AfterTargets="GenerateCoverageResultAfterTest" Condition=" '$(CollectCoverage)' == 'true' ">
2422
<ReportGenerator ReportFiles="@(CoverletReport)" ReportTypes="$(ReportGeneratorReportTypes)" Tag="$(Version)" TargetDirectory="$(ReportGeneratorTargetDirectory)" Title="$(AssemblyName)" VerbosityLevel="Warning" />
25-
<Exec Condition=" '$(ReportGeneratorOutputMarkdown)' == 'true' " Command="pwsh -Command %22('$(_MarkdownSummaryPrefix)' + [System.Environment]::NewLine + [System.Environment]::NewLine + (Get-Content $([System.IO.Path]::Combine($(ReportGeneratorTargetDirectory), 'SummaryGithub.md')) | Out-String) + [System.Environment]::NewLine + [System.Environment]::NewLine + '$(_MarkdownSummarySuffix)') >> $(GITHUB_STEP_SUMMARY)%22" />
23+
<PropertyGroup Condition=" '$(ReportGeneratorOutputMarkdown)' == 'true' ">
24+
<_ReportSummaryContent>&lt;details&gt;&lt;summary&gt;:chart_with_upwards_trend: &lt;b&gt;$(AssemblyName) Code Coverage report&lt;/b&gt;&lt;/summary&gt;</_ReportSummaryContent>
25+
<_ReportSummaryContent>$(_ReportSummaryContent)$([System.Environment]::NewLine)</_ReportSummaryContent>
26+
<_ReportSummaryContent>$(_ReportSummaryContent)$([System.Environment]::NewLine)</_ReportSummaryContent>
27+
<_ReportSummaryContent>$(_ReportSummaryContent)$([System.IO.File]::ReadAllText('$([System.IO.Path]::Combine($(ReportGeneratorTargetDirectory), 'SummaryGithub.md'))'))</_ReportSummaryContent>
28+
<_ReportSummaryContent>$(_ReportSummaryContent)$([System.Environment]::NewLine)</_ReportSummaryContent>
29+
<_ReportSummaryContent>$(_ReportSummaryContent)$([System.Environment]::NewLine)</_ReportSummaryContent>
30+
<_ReportSummaryContent>$(_ReportSummaryContent)&lt;/details&gt;</_ReportSummaryContent>
31+
</PropertyGroup>
32+
<WriteLinesToFile Condition=" '$(ReportGeneratorOutputMarkdown)' == 'true' " ContinueOnError="WarnAndContinue" File="$(GITHUB_STEP_SUMMARY)" Lines="$(_ReportSummaryContent)" />
2633
</Target>
2734
</Project>

test/Swashbuckle.AspNetCore.IntegrationTests/CustomDocumentSerializerTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Swashbuckle.AspNetCore.IntegrationTests
1212
{
13+
[Collection("TestSite")]
1314
public class CustomDocumentSerializerTests
1415
{
1516
[Fact]

test/Swashbuckle.AspNetCore.IntegrationTests/DocumentProviderTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Swashbuckle.AspNetCore.IntegrationTests
1111
{
12+
[Collection("TestSite")]
1213
public class DocumentProviderTests
1314
{
1415
[Theory]

test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Swashbuckle.AspNetCore.IntegrationTests
77
{
8+
[Collection("TestSite")]
89
public class ReDocIntegrationTests
910
{
1011
[Fact]
@@ -58,4 +59,4 @@ public async Task RedocMiddleware_CanBeConfiguredMultipleTimes(string redocUrl,
5859
Assert.Contains(swaggerPath, content);
5960
}
6061
}
61-
}
62+
}

test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerIntegrationTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Swashbuckle.AspNetCore.IntegrationTests
1313
{
14+
[Collection("TestSite")]
1415
public class SwaggerIntegrationTests
1516
{
1617
[Theory]

test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Swashbuckle.AspNetCore.IntegrationTests
77
{
8+
[Collection("TestSite")]
89
public class SwaggerUIIntegrationTests
910
{
1011
[Theory]
@@ -88,4 +89,4 @@ public async Task SwaggerUIMiddleware_CanBeConfiguredMultipleTimes(string swagge
8889
}
8990
}
9091
}
91-
}
92+
}

0 commit comments

Comments
 (0)