diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index bf7570239d6..8539502b9e3 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -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 + - 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: | + # 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: - lfs: true - - name: Setup .NET 8.0 - uses: actions/setup-dotnet@v4 + 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: - dotnet-version: '8.0.x' - - name: Install dev certs - run: dotnet --version && dotnet dev-certs https --trust - - 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 - - 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" + files: ${{ github.workspace }}/dotnet/coverage-report/*.xml + flags: unittests + name: dotnet-codecov + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} integration-test: strategy: diff --git a/dotnet/test/Microsoft.AutoGen.Core.Grpc.Tests/Microsoft.AutoGen.Core.Grpc.Tests.csproj b/dotnet/test/Microsoft.AutoGen.Core.Grpc.Tests/Microsoft.AutoGen.Core.Grpc.Tests.csproj index e3573c93451..4f67d972782 100644 --- a/dotnet/test/Microsoft.AutoGen.Core.Grpc.Tests/Microsoft.AutoGen.Core.Grpc.Tests.csproj +++ b/dotnet/test/Microsoft.AutoGen.Core.Grpc.Tests/Microsoft.AutoGen.Core.Grpc.Tests.csproj @@ -8,6 +8,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/dotnet/test/Microsoft.AutoGen.Core.Tests/Microsoft.AutoGen.Core.Tests.csproj b/dotnet/test/Microsoft.AutoGen.Core.Tests/Microsoft.AutoGen.Core.Tests.csproj index 29165739b63..eed47c6238b 100644 --- a/dotnet/test/Microsoft.AutoGen.Core.Tests/Microsoft.AutoGen.Core.Tests.csproj +++ b/dotnet/test/Microsoft.AutoGen.Core.Tests/Microsoft.AutoGen.Core.Tests.csproj @@ -8,6 +8,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/dotnet/test/Microsoft.AutoGen.Runtime.Grpc.Tests/GrpcGatewayServiceTests.cs b/dotnet/test/Microsoft.AutoGen.Runtime.Grpc.Tests/GrpcGatewayServiceTests.cs index 90b6b2dddcf..fcae1ec3dcd 100644 --- a/dotnet/test/Microsoft.AutoGen.Runtime.Grpc.Tests/GrpcGatewayServiceTests.cs +++ b/dotnet/test/Microsoft.AutoGen.Runtime.Grpc.Tests/GrpcGatewayServiceTests.cs @@ -12,7 +12,7 @@ namespace Microsoft.AutoGen.Runtime.Grpc.Tests; [Collection(ClusterCollection.Name)] -[Trait("Category", "UnitV2")] +[Trait("Category", "GRPC")] public class GrpcGatewayServiceTests { private readonly ClusterFixture _fixture; diff --git a/dotnet/test/Microsoft.AutoGen.Runtime.Grpc.Tests/Microsoft.AutoGen.Runtime.Grpc.Tests.csproj b/dotnet/test/Microsoft.AutoGen.Runtime.Grpc.Tests/Microsoft.AutoGen.Runtime.Grpc.Tests.csproj index ab0899c0f16..c8b00ee268b 100644 --- a/dotnet/test/Microsoft.AutoGen.Runtime.Grpc.Tests/Microsoft.AutoGen.Runtime.Grpc.Tests.csproj +++ b/dotnet/test/Microsoft.AutoGen.Runtime.Grpc.Tests/Microsoft.AutoGen.Runtime.Grpc.Tests.csproj @@ -8,6 +8,10 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive + all +