зеркало из https://github.com/microsoft/testfx.git
Add codecov.io (#3701)
This commit is contained in:
Родитель
0c8d78b445
Коммит
54bde5f889
|
@ -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
|
||||
|
|
|
@ -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=""$(_ReportGeneratorPath)" "-reports:@(_CoverageReports)" -targetdir:$(ArtifactsCoverageDir)full -reporttypes:Cobertura -filefilters:-*.g.cs" />
|
||||
<Exec Condition="'@(_CoverageReports)' != ''" Command=""$(_ReportGeneratorPath)" "-reports:@(_CoverageReports)" -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=""$(_ReportGeneratorPath)" "-reports:@(_UnitCoverageReports)" -targetdir:$(ArtifactsCoverageDir)unit -reporttypes:Cobertura -filefilters:-*.g.cs" />
|
||||
<Exec Condition="'@(_UnitCoverageReports)' != ''" Command=""$(_ReportGeneratorPath)" "-reports:@(_UnitCoverageReports)" -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=""$(_ReportGeneratorPath)" "-reports:@(_IntegrationCoverageReports)" -targetdir:$(ArtifactsCoverageDir)integration -reporttypes:Cobertura -filefilters:-*.g.cs" />
|
||||
<Exec Condition="'@(_IntegrationCoverageReports)' != ''" Command=""$(_ReportGeneratorPath)" "-reports:@(_IntegrationCoverageReports)" -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=""$(_CodecovPath)" @(_CodecovUnitArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovProductionUnitFlags, ',')" />
|
||||
<Exec Condition="'@(_UnitCoverageReports)' != ''" Command=""$(_CodecovPath)" @(_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=""$(_CodecovPath)" @(_CodecovIntegrationArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovProductionIntegrationFlags, ',')" />
|
||||
<Exec Condition="'@(_IntegrationCoverageReports)' != ''" Command=""$(_CodecovPath)" @(_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=""$(_CodecovPath)" @(_CodecovFullArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovTestFlags, ',')" />
|
||||
<Exec Condition="'@(_CoverageReports)' != ''" Command=""$(_CodecovPath)" @(_CodecovFullArgs, ' ') @(_CodecovArgs, ' ') --flag @(_CodecovTestFlags, ',')" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
Загрузка…
Ссылка в новой задаче