From ac85c8c7b48818eb7eb7d62862e12b7f3d315706 Mon Sep 17 00:00:00 2001 From: Markus Palcer Date: Sat, 17 Jan 2026 10:37:20 +0100 Subject: [PATCH 1/4] add coverage report to MR --- .github/workflows/pr.yml | 9 +++++++ AtemSharp.Tests/AtemSharp.Tests.csproj | 5 +++- Run-Coverage.ps1 | 37 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 Run-Coverage.ps1 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 49c6d70..57eecac 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -22,6 +22,15 @@ jobs: - name: Build run: dotnet build -c Release + - name: Capture Coverage + run: RunCoverage.ps1 + + - name: Upload Coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage-report + - name: Mutation testing run: | dotnet tool restore diff --git a/AtemSharp.Tests/AtemSharp.Tests.csproj b/AtemSharp.Tests/AtemSharp.Tests.csproj index 314657f..a207265 100644 --- a/AtemSharp.Tests/AtemSharp.Tests.csproj +++ b/AtemSharp.Tests/AtemSharp.Tests.csproj @@ -9,7 +9,10 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Run-Coverage.ps1 b/Run-Coverage.ps1 new file mode 100644 index 0000000..3f2d775 --- /dev/null +++ b/Run-Coverage.ps1 @@ -0,0 +1,37 @@ +# Remove old reports +Get-ChildItem -Path . -Recurse -Filter coverage.cobertura.xml | Remove-Item + +# Stop the script immediately on any error +$ErrorActionPreference = "Stop" + +# Run tests with coverage collection +dotnet test --collect:"XPlat Code Coverage" + +# Find the latest coverage.cobertura.xml file under TestResults +$coverageFiles = Get-ChildItem -Path . -Recurse -Filter coverage.cobertura.xml + +if ($coverageFiles.Count -eq 0) { + Write-Error "No coverage report files found!" + exit 1 +} + +# Collect full paths of all coverage files +$coveragePaths = $coverageFiles | ForEach-Object { $_.FullName } + +# Join paths with semicolon (and quote the whole string for safety) +$reportsArg = '"' + ($coveragePaths -join ";") + '"' + +# Build the report output path +$targetDir = "coverage-report" +$reportType = "Html" + +# Generate combined HTML report +dotnet tool restore +dotnet tool run reportgenerator ` + -reports:$reportsArg ` + "-targetdir:$targetDir" ` + "-filefilters:-*.g.cs" ` + "-reporttypes:$reportType" + +New-Item -Path "$targetDir" -Name ".gitignore" -ItemType "File" -Value "*" -Force +Write-Host "Coverage report written to coverage-report\index.html" From c6a1a01ca7804c64b81f4ad91fb4be77a8ea23ed Mon Sep 17 00:00:00 2001 From: Markus Palcer Date: Sat, 17 Jan 2026 10:44:20 +0100 Subject: [PATCH 2/4] fix --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 57eecac..e4b5ae0 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,7 +23,7 @@ jobs: run: dotnet build -c Release - name: Capture Coverage - run: RunCoverage.ps1 + run: .\RunCoverage.ps1 - name: Upload Coverage report uses: actions/upload-artifact@v4 From 6cf5dd8b4864eec22ce6cc7e095b379b8beb4c50 Mon Sep 17 00:00:00 2001 From: Markus Palcer Date: Sat, 17 Jan 2026 10:47:09 +0100 Subject: [PATCH 3/4] fix --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e4b5ae0..dc1a30b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,6 +23,7 @@ jobs: run: dotnet build -c Release - name: Capture Coverage + shell: pwsh run: .\RunCoverage.ps1 - name: Upload Coverage report From e7aadb2cba68ebdb21d10b5b6eb4e7156cf01173 Mon Sep 17 00:00:00 2001 From: Markus Palcer Date: Sat, 17 Jan 2026 10:53:16 +0100 Subject: [PATCH 4/4] fix --- .github/workflows/pr.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index dc1a30b..422f001 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -17,14 +17,22 @@ jobs: dotnet-version: '9.0.x' - name: Restore packages - run: nuget restore + run: dotnet restore + + - name: Restore tools + run: dotnet tool restore - name: Build run: dotnet build -c Release - name: Capture Coverage shell: pwsh - run: .\RunCoverage.ps1 + run: | + dotnet test --collect:"XPlat Code Coverage" + $coverageFiles = Get-ChildItem -Path . -Recurse -Filter coverage.cobertura.xml + $coveragePaths = $coverageFiles | ForEach-Object { $_.FullName } + $reportsArg = '"' + ($coveragePaths -join ";") + '"' + dotnet tool run reportgenerator -reports:$reportsArg "-targetdir:coverage-report" "-filefilters:-*.g.cs" "-reporttypes:$reportType" - name: Upload Coverage report uses: actions/upload-artifact@v4