Skip to content

Commit 84da057

Browse files
authored
Use vstest Cobertura support (#1177)
* Use vstest Cobertura support Thanks to microsoft/vstest#2874 Cobertura reports can be obtained faster without coverlet. * Update Kubectl.Tests.csproj * Update KubernetesClient.Classic.Tests.csproj * Update KubernetesClient.Tests.csproj * Update buildtest.yaml * Update AbstractKubernetes.cs.template * Update IBasicKubernetes.cs.template * Update IOperations.cs.template * Update Model.cs.template * Add filter * revert
1 parent 10f4951 commit 84da057

File tree

5 files changed

+57
-21
lines changed

5 files changed

+57
-21
lines changed

.github/workflows/buildtest.yaml

+16-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ jobs:
2424
- name: Build
2525
run: dotnet build --configuration Release -v detailed
2626
- name: Test
27-
run: dotnet test /p:CollectCoverage=true /p:ExcludeByFile=\"**/KubernetesClient/generated/**/*.cs\" /p:CoverletOutputFormat="cobertura"
28-
27+
run: dotnet test --configuration Release --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory TestResults --settings CodeCoverage.runsettings --no-build
28+
- name: Upload coverage to Codecov
29+
uses: codecov/codecov-action@v3
30+
with:
31+
directory: ./TestResults
32+
files: '*.cobertura.xml'
33+
- name: Upload test results
34+
uses: actions/upload-artifact@v3
35+
with:
36+
name: test-results
37+
path: ./TestResults
38+
if: ${{ always() }} # Always run this step even on failure
39+
2940
# Test code gen for visual studio compatibility >> https://github.com/kubernetes-client/csharp/pull/1008
3041
codgen:
3142
runs-on: windows-latest
@@ -39,12 +50,12 @@ jobs:
3950
- name: Setup dotnet SDK 7
4051
uses: actions/setup-dotnet@v3
4152
with:
42-
dotnet-version: '7.0.x'
53+
dotnet-version: '7.0.x'
4354
- name: Restore nugets (msbuild)
4455
run: msbuild .\src\KubernetesClient.Models\ -t:restore -p:RestorePackagesConfig=true
4556
- name: Build (msbuild)
4657
run: msbuild .\src\KubernetesClient.Models\
47-
58+
4859
e2e:
4960
runs-on: ubuntu-latest
5061
steps:
@@ -67,7 +78,7 @@ jobs:
6778
cat skip.log
6879
echo "CASES MUST NOT BE SKIPPED"
6980
exit 1
70-
fi
81+
fi
7182
7283
on:
7384
pull_request:

CodeCoverage.runsettings

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RunSettings>
3+
<DataCollectionRunSettings>
4+
<DataCollectors>
5+
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0">
6+
<Configuration>
7+
<CodeCoverage>
8+
<ModulePaths>
9+
<Include>
10+
<ModulePath>.*KubernetesClient\..*\.dll$</ModulePath>
11+
</Include>
12+
<Exclude>
13+
<ModulePath>.*tests\.dll$</ModulePath>
14+
<ModulePath>.*xunit.*dll$</ModulePath>
15+
<ModulePath>.*moq\.dll$</ModulePath>
16+
<ModulePath>.*System\.Reactive\.dll$</ModulePath>
17+
<ModulePath>.*BouncyCastle\.Crypto\.dll$</ModulePath>
18+
<ModulePath>.*IdentityModel\.OidcClient\.dll$</ModulePath>
19+
</Exclude>
20+
</ModulePaths>
21+
<!-- Set this to True to collect coverage information for functions marked with the "SecuritySafeCritical" attribute. Instead of writing directly into a memory location from such functions, code coverage inserts a probe that redirects to another function, which in turns writes into memory. -->
22+
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
23+
<!-- When set to True, collects coverage information from child processes that are launched with low-level ACLs, for example, UWP apps. -->
24+
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
25+
<!-- When set to True, collects coverage information from child processes that are launched by test or production code. -->
26+
<CollectFromChildProcesses>True</CollectFromChildProcesses>
27+
<Attributes>
28+
<Exclude>
29+
<Attribute>^System.ObsoleteAttribute$</Attribute>
30+
<Attribute>^System.CodeDom.Compiler.GeneratedCodeAttribute$</Attribute>
31+
<Attribute>^System.Diagnostics.DebuggerHiddenAttribute$</Attribute>
32+
<Attribute>^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
33+
</Exclude>
34+
</Attributes>
35+
</CodeCoverage>
36+
</Configuration>
37+
</DataCollector>
38+
</DataCollectors>
39+
</DataCollectionRunSettings>
40+
</RunSettings>

tests/Kubectl.Tests/Kubectl.Tests.csproj

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
</PropertyGroup>
1010
<ItemGroup>
1111

12-
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
13-
<PrivateAssets>all</PrivateAssets>
14-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
15-
</PackageReference>
16-
1712
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
1813
<PackageReference Include="xunit" Version="2.4.2" />
1914
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
@@ -36,4 +31,4 @@
3631
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3732
</AdditionalFiles>
3833
</ItemGroup>
39-
</Project>
34+
</Project>

tests/KubernetesClient.Classic.Tests/KubernetesClient.Classic.Tests.csproj

-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818

1919
<ItemGroup>
2020

21-
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
22-
<PrivateAssets>all</PrivateAssets>
23-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
24-
</PackageReference>
25-
2621
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
2722
<PackageReference Include="xunit" Version="2.4.2" />
2823
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj

-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717

1818
<ItemGroup>
1919

20-
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
21-
<PrivateAssets>all</PrivateAssets>
22-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
23-
</PackageReference>
24-
2520
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
2621
<PackageReference Include="xunit" Version="2.4.2" />
2722
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

0 commit comments

Comments
 (0)