Skip to content

Commit

Permalink
Use vstest Cobertura support (#1177)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
stan-sz committed Feb 11, 2023
1 parent 10f4951 commit 84da057
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 21 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/buildtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@ jobs:
- name: Build
run: dotnet build --configuration Release -v detailed
- name: Test
run: dotnet test /p:CollectCoverage=true /p:ExcludeByFile=\"**/KubernetesClient/generated/**/*.cs\" /p:CoverletOutputFormat="cobertura"

run: dotnet test --configuration Release --collect:"Code Coverage;Format=Cobertura" --logger trx --results-directory TestResults --settings CodeCoverage.runsettings --no-build
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
directory: ./TestResults
files: '*.cobertura.xml'
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: test-results
path: ./TestResults
if: ${{ always() }} # Always run this step even on failure

# Test code gen for visual studio compatibility >> https://github.com/kubernetes-client/csharp/pull/1008
codgen:
runs-on: windows-latest
Expand All @@ -39,12 +50,12 @@ jobs:
- name: Setup dotnet SDK 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '7.0.x'
- name: Restore nugets (msbuild)
run: msbuild .\src\KubernetesClient.Models\ -t:restore -p:RestorePackagesConfig=true
- name: Build (msbuild)
run: msbuild .\src\KubernetesClient.Models\

e2e:
runs-on: ubuntu-latest
steps:
Expand All @@ -67,7 +78,7 @@ jobs:
cat skip.log
echo "CASES MUST NOT BE SKIPPED"
exit 1
fi
fi
on:
pull_request:
Expand Down
40 changes: 40 additions & 0 deletions CodeCoverage.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*KubernetesClient\..*\.dll$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*tests\.dll$</ModulePath>
<ModulePath>.*xunit.*dll$</ModulePath>
<ModulePath>.*moq\.dll$</ModulePath>
<ModulePath>.*System\.Reactive\.dll$</ModulePath>
<ModulePath>.*BouncyCastle\.Crypto\.dll$</ModulePath>
<ModulePath>.*IdentityModel\.OidcClient\.dll$</ModulePath>
</Exclude>
</ModulePaths>
<!-- 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. -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<!-- When set to True, collects coverage information from child processes that are launched with low-level ACLs, for example, UWP apps. -->
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<!-- When set to True, collects coverage information from child processes that are launched by test or production code. -->
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<Attributes>
<Exclude>
<Attribute>^System.ObsoleteAttribute$</Attribute>
<Attribute>^System.CodeDom.Compiler.GeneratedCodeAttribute$</Attribute>
<Attribute>^System.Diagnostics.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
7 changes: 1 addition & 6 deletions tests/Kubectl.Tests/Kubectl.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
</PropertyGroup>
<ItemGroup>

<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand All @@ -36,4 +31,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</AdditionalFiles>
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@

<ItemGroup>

<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
5 changes: 0 additions & 5 deletions tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@

<ItemGroup>

<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down

0 comments on commit 84da057

Please sign in to comment.