Skip to content

Commit 4a394d5

Browse files
committed
Update code coverage integration
1 parent 01c719e commit 4a394d5

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

build/Codecoverage.proj

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,24 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Codecov" Version="$(CodecovVersion)" />
10-
<PackageReference Include="ReportGenerator" Version="$(ReportGeneratorVersion)" />
9+
<PackageReference Include="Codecov" Version="$(CodecovVersion)" GeneratePathProperty="true" />
10+
<PackageReference Include="ReportGenerator" Version="$(ReportGeneratorVersion)" GeneratePathProperty="true" />
1111
</ItemGroup>
12-
<Target Name="Codecov" DependsOnTargets="Restore">
12+
13+
<Target Name="Codecov">
1314
<PropertyGroup>
14-
<_CodecovPath>$(RestorePackagesPath)codecov\$(CodecovVersion)\tools\Codecov.exe</_CodecovPath>
15-
<_ReportGeneratorPath>$(RestorePackagesPath)reportgenerator\$(ReportGeneratorVersion)\tools\net47\ReportGenerator.exe</_ReportGeneratorPath>
16-
<_BranchName Condition="'$(_BranchName)' == ''">$(SYSTEM_PULLREQUEST_SOURCEBRANCH)</_BranchName>
17-
<_BranchName Condition="'$(_BranchName)' == ''">$(BUILD_SOURCEBRANCHNAME)</_BranchName>
15+
<_CodecovPath>$(PkgCodecov)\tools\Codecov.exe</_CodecovPath>
16+
<_ReportGeneratorPath>$(PkgReportGenerator)\tools\net47\ReportGenerator.exe</_ReportGeneratorPath>
1817
</PropertyGroup>
1918

2019
<Message Importance="high" Text="&quot;$(_ReportGeneratorPath)&quot; -reports:$(BaseOutputPath)$(PlatformConfig)\coverage\*.coverage -targetdir:$(BaseOutputPath)$(PlatformConfig)\coverage -filefilters:+https*;+*.fs -reporttypes:Cobertura" />
2120
<Exec Command="&quot;$(_ReportGeneratorPath)&quot; -reports:$(BaseOutputPath)$(PlatformConfig)\coverage\*.coverage -targetdir:$(BaseOutputPath)$(PlatformConfig)\coverage -filefilters:+https*;+*.fs -reporttypes:Cobertura" />
2221

2322
<ItemGroup>
2423
<_CodecovArgs Include="-f;$(BaseOutputPath)$(PlatformConfig)\coverage\Cobertura.xml" />
25-
<_CodecovArgs Include="-r;$(BUILD_REPOSITORY_NAME)" Condition="'$(BUILD_REPOSITORY_NAME)' != ''" />
26-
<_CodecovArgs Include="--pr;$(SYSTEM_PULLREQUEST_PULLREQUESTNUMBER)" Condition="'$(SYSTEM_PULLREQUEST_PULLREQUESTNUMBER)' != ''" />
27-
<_CodecovArgs Include="-b;$(BUILD_BUILDNUMBER)" Condition="'$(BUILD_BUILDNUMBER)' != ''" />
28-
<_CodecovArgs Include="--branch;$(_BranchName)" Condition="'$(_BranchName)' != ''" />
29-
<_CodecovArgs Include="-c;$(BUILD_SOURCEVERSION)" Condition="'$(BUILD_SOURCEVERSION)' != ''" />
30-
<_CodecovArgs Include="-n;$(BUILD_DEFINITIONNAME)" Condition="'$(BUILD_DEFINITIONNAME)' != ''" />
31-
<_CodecovArgs Include="-t;$(CodeCovToken)" Condition="'$(CodeCovToken)' != ''" />
24+
25+
<!-- Report an error if the upload fails -->
26+
<_CodecovArgs Include="--required" />
3227

3328
<_CodecovFlags Include="$(Configuration)" Condition="'$(Configuration)' != ''" />
3429
<_CodecovProductionFlags Include="@(_CodecovFlags)" />

build/Dependencies.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
<!-- Build/infrastructure Dependencies -->
3838
<PropertyGroup>
3939
<PublishSymbolsPackageVersion>1.0.0-beta-62824-02</PublishSymbolsPackageVersion>
40-
<CodecovVersion>1.7.2</CodecovVersion>
41-
<CoverletVersion>2.6.0</CoverletVersion>
42-
<ReportGeneratorVersion>4.0.9</ReportGeneratorVersion>
40+
<CodecovVersion>1.9.0</CodecovVersion>
41+
<CoverletVersion>2.7.0</CoverletVersion>
42+
<ReportGeneratorVersion>4.3.6</ReportGeneratorVersion>
4343
<MicrosoftDotNetApiCompatPackageVersion>1.0.0-beta.19225.5</MicrosoftDotNetApiCompatPackageVersion>
4444
</PropertyGroup>
4545

build/ci/job-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
displayName: Download Benchmark Data
6767
- script: ${{ parameters.buildScript }} -$(_configuration) -runtests -coverage=${{ parameters.codeCoverage }}
6868
displayName: Run Tests.
69-
- script: $(Build.SourcesDirectory)/Tools/dotnetcli/dotnet msbuild build/Codecoverage.proj /p:CodeCovToken=$(CODECOV_TOKEN)
69+
- script: $(Build.SourcesDirectory)/Tools/dotnetcli/dotnet msbuild -restore build/Codecoverage.proj
7070
displayName: Upload coverage to codecov.io
7171
condition: and(succeeded(), eq(${{ parameters.codeCoverage }}, True))
7272
- task: PublishTestResults@2

test/Directory.Build.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
</ItemGroup>
3535

3636
<PropertyGroup Condition="'$(Coverage)' == 'true'">
37+
<!-- https://github.com/tonerdo/coverlet/issues/618 -->
38+
<IncludeTestAssembly>true</IncludeTestAssembly>
39+
3740
<CollectCoverage>true</CollectCoverage>
3841
<SingleHit>true</SingleHit>
3942
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- https://github.com/tonerdo/coverlet/issues/72 -->

0 commit comments

Comments
 (0)