This commit is contained in:
Amaury Levé 2024-08-28 11:37:44 +02:00 коммит произвёл GitHub
Родитель 0c8d78b445
Коммит 54bde5f889
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 109 добавлений и 0 удалений

14
.github/codecov.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,14 @@
# https://docs.codecov.io/docs/codecov-yaml
# https://github.com/codecov/support/wiki/Codecov-Yaml
coverage:
status:
project:
default: false
patch:
default: false
fixes:
- "eng/src/::src/"
comment:
layout: "diff"

Просмотреть файл

@ -55,6 +55,7 @@
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
<ItemGroup Label="Test dependencies">
<PackageVersion Include="Codecov" Version="1.12.3" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="FSharp.Core" Version="8.0.200" />
<!-- Pinned to 4.18.4 for security -->
@ -66,6 +67,7 @@
<PackageVersion Include="NuGet.Packaging" Version="6.10.0" />
<PackageVersion Include="Polly" Version="8.4.1" />
<PackageVersion Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageVersion Include="ReportGenerator" Version="4.3.6" />
<PackageVersion Include="StreamJsonRpc" Version="2.18.48" />
<PackageVersion Include="StrongNamer" Version="0.2.5" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />

Просмотреть файл

@ -108,6 +108,14 @@ stages:
name: Test
displayName: Test
# Upload code coverage data
- script: $(Build.SourcesDirectory)/.dotnet/dotnet msbuild -restore
eng/CodeCoverage.proj
/p:Configuration=$(_BuildConfig)
/bl:$(BUILD.SOURCESDIRECTORY)\artifacts\log\$(_BuildConfig)\CodeCoverage.binlog
displayName: Upload coverage to codecov.io
condition: and(succeeded(), eq(variables._BuildConfig, 'Debug'))
# This step is only helpful for diagnosing some issues with vstest/test host that would not appear
# through the console or trx
- task: PublishBuildArtifacts@1

85
eng/CodeCoverage.proj Normal file
Просмотреть файл

@ -0,0 +1,85 @@
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Codecov">
<PropertyGroup>
<!-- We need to specify a framework in order for the Restore target to work -->
<TargetFramework>$(NetCurrent)</TargetFramework>
<ArtifactsCoverageDir>$(ArtifactsDir)coverage\</ArtifactsCoverageDir>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Codecov" Version="$(CodecovVersion)" GeneratePathProperty="true" />
<PackageReference Include="ReportGenerator" Version="$(ReportGeneratorVersion)" GeneratePathProperty="true" />
</ItemGroup>
<Target Name="GatherCoverageInputs">
<PropertyGroup>
<_CodecovPath>$(PkgCodecov)\tools\Codecov.exe</_CodecovPath>
<_ReportGeneratorPath>$(PkgReportGenerator)\tools\net47\ReportGenerator.exe</_ReportGeneratorPath>
</PropertyGroup>
<ItemGroup>
<_CoverageReports Include="$(ArtifactsTestResultsDir)\*.coverage" />
<_UnitCoverageReports Include="@(_CoverageReports)" Condition="$([System.String]::Copy('%(Identity)').Contains('.UnitTests_'))" />
<_IntegrationCoverageReports Include="@(_CoverageReports)" Condition="$([System.String]::Copy('%(Identity)').Contains('.IntegrationTests_'))" />
</ItemGroup>
</Target>
<Target Name="MergeCoverage" DependsOnTargets="GatherCoverageInputs">
<!-- Merge multiple coverlet reports into a single Cobertura report before uploading to codecov.io, in order to
reduce upload size and load on the codecov.io processing servers. -->
<Message Importance="high" Text="&quot;$(_ReportGeneratorPath)&quot; &quot;-reports:@(_CoverageReports)&quot; -targetdir:$(ArtifactsCoverageDir)full -reporttypes:Cobertura -filefilters:-*.g.cs" />
<Exec Condition="'@(_CoverageReports)' != ''" Command="&quot;$(_ReportGeneratorPath)&quot; &quot;-reports:@(_CoverageReports)&quot; -targetdir:$(ArtifactsCoverageDir)/full -reporttypes:Cobertura -filefilters:-*.g.cs" />
<!-- Merge multiple coverlet reports into a single Cobertura report before uploading to codecov.io, in order to
reduce upload size and load on the codecov.io processing servers. -->
<Message Importance="high" Text="&quot;$(_ReportGeneratorPath)&quot; &quot;-reports:@(_UnitCoverageReports)&quot; -targetdir:$(ArtifactsCoverageDir)unit -reporttypes:Cobertura -filefilters:-*.g.cs" />
<Exec Condition="'@(_UnitCoverageReports)' != ''" Command="&quot;$(_ReportGeneratorPath)&quot; &quot;-reports:@(_UnitCoverageReports)&quot; -targetdir:$(ArtifactsCoverageDir)/unit -reporttypes:Cobertura -filefilters:-*.g.cs" />
<!-- Merge multiple coverlet reports into a single Cobertura report before uploading to codecov.io, in order to
reduce upload size and load on the codecov.io processing servers. -->
<Message Importance="high" Text="&quot;$(_ReportGeneratorPath)&quot; &quot;-reports:@(_IntegrationCoverageReports)&quot; -targetdir:$(ArtifactsCoverageDir)integration -reporttypes:Cobertura -filefilters:-*.g.cs" />
<Exec Condition="'@(_IntegrationCoverageReports)' != ''" Command="&quot;$(_ReportGeneratorPath)&quot; &quot;-reports:@(_IntegrationCoverageReports)&quot; -targetdir:$(ArtifactsCoverageDir)/integration -reporttypes:Cobertura -filefilters:-*.g.cs" />
</Target>
<Target Name="Codecov" DependsOnTargets="MergeCoverage">
<ItemGroup>
<_CodecovFullArgs Include="-f;$(ArtifactsCoverageDir)full\Cobertura.xml" />
<_CodecovUnitArgs Include="-f;$(ArtifactsCoverageDir)unit\Cobertura.xml" />
<_CodecovIntegrationArgs Include="-f;$(ArtifactsCoverageDir)integration\Cobertura.xml" />
<!-- Report an error if the upload fails -->
<_CodecovArgs Include="--required" />
<_CodecovFlags Include="$(Configuration)" Condition="'$(Configuration)' != ''" />
<_CodecovProductionFlags Include="@(_CodecovFlags)" />
<_CodecovProductionFlags Include="production" />
<_CodecovTestFlags Include="@(_CodecovFlags)" />
<_CodecovTestFlags Include="test" />
<_CodecovProductionUnitFlags Include="@(_CodecovProductionFlags)" />
<_CodecovProductionUnitFlags Include="unit" />
<_CodecovTestUnitFlags Include="@(_CodecovTestFlags)" />
<_CodecovTestUnitFlags Include="unit" />
<_CodecovProductionIntegrationFlags Include="@(_CodecovProductionFlags)" />
<_CodecovProductionIntegrationFlags Include="integration" />
<_CodecovTestIntegrationFlags Include="@(_CodecovTestFlags)" />
<_CodecovTestIntegrationFlags Include="integration" />
</ItemGroup>
<!-- Upload the unit test coverage file with a 'production' flag, which will be filtered by codecov.io to production code -->
<Message Importance="high" Text="&quot;$(_CodecovPath)&quot; @(_CodecovUnitArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovProductionUnitFlags, ',')" />
<Exec Condition="'@(_UnitCoverageReports)' != ''" Command="&quot;$(_CodecovPath)&quot; @(_CodecovUnitArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovProductionUnitFlags, ',')" />
<!-- Upload the integration test coverage file with a 'production' flag, which will be filtered by codecov.io to production code -->
<Message Importance="high" Text="&quot;$(_CodecovPath)&quot; @(_CodecovIntegrationArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovProductionIntegrationFlags, ',')" />
<Exec Condition="'@(_IntegrationCoverageReports)' != ''" Command="&quot;$(_CodecovPath)&quot; @(_CodecovIntegrationArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovProductionIntegrationFlags, ',')" />
<!-- Upload the full test coverage file with a 'test' flag, which will be filtered by codecov.io to test code. We
don't further separate this by integration vs. unit tests because the answer is clear from the file path. -->
<Message Importance="high" Text="&quot;$(_CodecovPath)&quot; @(_CodecovFullArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovTestFlags, ',')" />
<Exec Condition="'@(_CoverageReports)' != ''" Command="&quot;$(_CodecovPath)&quot; @(_CodecovFullArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovTestFlags, ',')" />
</Target>
</Project>