feat: add dotnet code coverage (#5403)

This commit is contained in:
Griffin Bassman
2025-02-06 14:30:15 -05:00
committed by GitHub
parent ca428914f5
commit da6f918708
5 changed files with 52 additions and 59 deletions
+39 -58
View File
@@ -46,8 +46,9 @@ jobs:
- name: workflows has changes
run: echo "workflows has changes"
if: steps.filter.outputs.workflows == 'true'
build:
name: Dotnet Build
name: Dotnet Build & Test
needs: paths-filter
if: needs.paths-filter.outputs.hasChanges == 'true'
defaults:
@@ -64,35 +65,12 @@ jobs:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install jupyter and ipykernel
run: |
python -m pip install --upgrade pip
python -m pip install jupyter
python -m pip install ipykernel
- name: list available kernels
run: |
python -m jupyter kernelspec list
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
version: "0.5.18"
- run: uv sync --locked --all-extras
working-directory: ./python
- name: Prepare python venv
run: |
source ${{ github.workspace }}/python/.venv/bin/activate
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: |
# dotnet nuget add source --name dotnet-tool https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json --configfile NuGet.config
dotnet restore -bl
run: dotnet restore -bl
- name: Format check
run: |
echo "Format check"
@@ -104,40 +82,43 @@ jobs:
dotnet build --no-restore --configuration Release -bl /p:SignAssembly=true
- name: Unit Test V1
run: dotnet test --no-build -bl --configuration Release --filter "Category=UnitV1"
- name: Unit Test V2
run: dotnet test --no-build -bl --configuration Release --filter "Category=UnitV2"
grpc-unit-tests:
name: Dotnet Grpc unit tests
needs: paths-filter
if: needs.paths-filter.outputs.hasChanges == 'true'
defaults:
run:
working-directory: dotnet
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install dev certs
run: dotnet --version && dotnet dev-certs https --trust
- name: Restore dependencies
- name: Unit Test V2 (With Coverage)
run: dotnet test --no-build -bl --configuration Release --filter "Category=UnitV2" --collect:"XPlat Code Coverage"
- name: Install Dev Certs for GRPC
if: matrix.os == 'ubuntu-latest'
run: dotnet dev-certs https --trust
- name: GRPC Tests (With Coverage)
if: matrix.os == 'ubuntu-latest'
run: dotnet test --no-build -bl --configuration Release --filter "Category=GRPC" --collect:"XPlat Code Coverage"
- name: Generate & Merge Coverage Report
if: matrix.os == 'ubuntu-latest'
run: |
# dotnet nuget add source --name dotnet-tool https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json --configfile NuGet.config
dotnet restore -bl
- name: Build
run: dotnet build --no-restore --configuration Release -bl /p:SignAssembly=true
- name: GRPC tests
run: dotnet test --no-build -bl --configuration Release --filter "Category=GRPC"
# Install reportgenerator
dotnet tool install -g dotnet-reportgenerator-globaltool || dotnet tool update -g dotnet-reportgenerator-globaltool
# Ensure output directory exists
mkdir -p ${{ github.workspace }}/dotnet/coverage-report
# Merge all coverage reports and generate HTML + XML
reportgenerator \
-reports:${{ github.workspace }}/dotnet/**/TestResults/**/coverage.cobertura.xml \
-targetdir:${{ github.workspace }}/dotnet/coverage-report \
-reporttypes:"Cobertura;Html"
ls -R ${{ github.workspace }}/dotnet/coverage-report
- name: Upload Merged Coverage Report
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: CodeCoverageReport
path: ${{ github.workspace }}/dotnet/coverage-report/
retention-days: 7
- name: Upload Coverage to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v5
with:
files: ${{ github.workspace }}/dotnet/coverage-report/*.xml
flags: unittests
name: dotnet-codecov
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
integration-test:
strategy:
@@ -8,6 +8,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<ProjectReference Include="..\..\src\Microsoft.AutoGen\Core\Microsoft.AutoGen.Core.csproj" />
<ProjectReference Include="..\..\src\Microsoft.AutoGen\Core.Grpc\Microsoft.AutoGen.Core.Grpc.csproj" />
<PackageReference Include="Microsoft.Extensions.Hosting" />
@@ -8,6 +8,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<ProjectReference Include="..\..\src\Microsoft.AutoGen\Core\Microsoft.AutoGen.Core.csproj" />
<PackageReference Include="Microsoft.Extensions.Hosting" />
</ItemGroup>
@@ -12,7 +12,7 @@ using NewMessageReceived = Tests.Events.NewMessageReceived;
namespace Microsoft.AutoGen.Runtime.Grpc.Tests;
[Collection(ClusterCollection.Name)]
[Trait("Category", "UnitV2")]
[Trait("Category", "GRPC")]
public class GrpcGatewayServiceTests
{
private readonly ClusterFixture _fixture;
@@ -8,6 +8,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.TestHost" />
<PackageReference Include="Microsoft.Orleans.TestingHost" />
</ItemGroup>