From 9c5d281982a2a6267268da538a63882ca7e3110e Mon Sep 17 00:00:00 2001 From: MarkZither Date: Sun, 16 Feb 2020 01:12:49 +0100 Subject: [PATCH] Track code coverage (#452) * Add coverlet.collector to test projects * Add steps to ci-official.yml to publish results Addresses https://github.com/loic-sharma/BaGet/issues/397 --- .azure/pipelines/ci-official.yml | 18 +++++++++++++++++- CodeCoverage.runsettings | 16 ++++++++++++++++ tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj | 4 ++++ .../BaGet.Protocol.Tests.csproj | 4 ++++ tests/BaGet.Tests/BaGet.Tests.csproj | 4 ++++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 CodeCoverage.runsettings diff --git a/.azure/pipelines/ci-official.yml b/.azure/pipelines/ci-official.yml index 788dba044..df954a489 100644 --- a/.azure/pipelines/ci-official.yml +++ b/.azure/pipelines/ci-official.yml @@ -65,7 +65,23 @@ jobs: inputs: command: test projects: '**/*Tests/*.csproj' - arguments: '--configuration $(BuildConfiguration)' + arguments: '--configuration $(BuildConfiguration) --settings $(System.DefaultWorkingDirectory)/CodeCoverage.runsettings --collect:"XPlat Code Coverage" -- RunConfiguration.DisableAppDomain=true' + + - task: DotNetCoreCLI@2 + inputs: + command: custom + custom: tool + arguments: install --tool-path . dotnet-reportgenerator-globaltool + displayName: Install ReportGenerator tool + + - script: reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"HtmlInline_AzurePipelines_Dark;Cobertura;Badges" + displayName: Create reports + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish code coverage' + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml - script: dotnet pack --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory) displayName: Pack diff --git a/CodeCoverage.runsettings b/CodeCoverage.runsettings new file mode 100644 index 000000000..f71a3aa61 --- /dev/null +++ b/CodeCoverage.runsettings @@ -0,0 +1,16 @@ + + + + + + + json,cobertura + Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute + false + true + true + + + + + \ No newline at end of file diff --git a/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj b/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj index afe3c5b9c..9fa366add 100644 --- a/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj +++ b/tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj @@ -12,6 +12,10 @@ all runtime; build; native; contentfiles; analyzers + + all + runtime; build; native; contentfiles; analyzers + diff --git a/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj b/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj index 28ef0c18a..58faaee99 100644 --- a/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj +++ b/tests/BaGet.Protocol.Tests/BaGet.Protocol.Tests.csproj @@ -12,6 +12,10 @@ all runtime; build; native; contentfiles; analyzers + + all + runtime; build; native; contentfiles; analyzers + diff --git a/tests/BaGet.Tests/BaGet.Tests.csproj b/tests/BaGet.Tests/BaGet.Tests.csproj index e1fc2f5fa..2e80d99c0 100644 --- a/tests/BaGet.Tests/BaGet.Tests.csproj +++ b/tests/BaGet.Tests/BaGet.Tests.csproj @@ -18,6 +18,10 @@ all runtime; build; native; contentfiles; analyzers + + all + runtime; build; native; contentfiles; analyzers +