From fe56f6fb29b44dd37e2dc491ef152b65afe07f06 Mon Sep 17 00:00:00 2001 From: George Pollard Date: Wed, 8 Jun 2022 13:52:31 +1200 Subject: [PATCH] Collect .NET coverage info (#2023) ## Summary of the Pull Request Collect .NET coverage during build and display it in GitHub Summary. ## Info on Pull Request Add the `reportgenerator` tool, run it after tests. ## Validation Steps Performed Run workflow and make sure it works. See example coverage output here: https://github.com/microsoft/onefuzz/actions/runs/2458088617 --- .github/workflows/ci.yml | 7 +++++-- src/ApiService/.config/dotnet-tools.json | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/ApiService/.config/dotnet-tools.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2324d7a8e..79d3fa7e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -267,6 +267,7 @@ jobs: run: | cd src/ApiService/ dotnet restore --locked-mode + dotnet tool restore - name: Check Formatting run: | cd src/ApiService/ @@ -275,10 +276,12 @@ jobs: run: | cd src/ApiService/ dotnet build -warnaserror --configuration Release - - name: Test + - name: Test & Collect coverage info run: | cd src/ApiService/ - dotnet test --no-restore + dotnet test --no-restore --collect:"XPlat Code Coverage" + dotnet tool run reportgenerator -reports:Tests/TestResults/*/coverage.cobertura.xml -targetdir:coverage -reporttypes:MarkdownSummary + cat coverage/*.md > $GITHUB_STEP_SUMMARY - name: copy artifacts run: | ./src/ci/get-version.sh > src/deployment/VERSION diff --git a/src/ApiService/.config/dotnet-tools.json b/src/ApiService/.config/dotnet-tools.json new file mode 100644 index 000000000..56434e1a1 --- /dev/null +++ b/src/ApiService/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-reportgenerator-globaltool": { + "version": "5.1.9", + "commands": [ + "reportgenerator" + ] + } + } +}