From a0d3a26f66f535c8c20b450de7430ad19d298de3 Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Wed, 2 Dec 2020 14:27:17 -0800 Subject: [PATCH] Do not generate reports with no coverage Fixes #17286 --- eng/CodeCoverage.targets | 22 +++++++++++++++++-- .../templates/jobs/archetype-sdk-client.yml | 9 +++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/eng/CodeCoverage.targets b/eng/CodeCoverage.targets index 297c676529b65..166abf15f19ef 100644 --- a/eng/CodeCoverage.targets +++ b/eng/CodeCoverage.targets @@ -24,16 +24,34 @@ - + + + + <_CoverageFiles Include="$(_TestResultsDirectory)\**\coverage.cobertura.xml" /> + + + <_CoverageCollected Condition="'@(_CoverageFiles)' != ''">true + + + + + + + DependsOnTargets="_SetCoverageCollected" + Condition="'$(_CollectCoverage)' == 'true' and '$(SkipCoverageReport)' != 'true' and '$(_CoverageCollected)' == 'true'"> dotnet tool run reportgenerator -- $(CoverageReportCommandLine) "-reports:$(_TestResultsDirectory)\**\coverage.cobertura.xml" diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 83b9816fc1369..9d9b5ea04c688 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -110,8 +110,6 @@ jobs: condition: and(succeededOrFailed(), ne(variables['Skip.Test'], true)) variables: - template: ../variables/globals.yml - - name: disable.coverage.autogenerate - value: true strategy: maxParallel: $[ variables['MaxParallelTestJobs'] ] matrix: @@ -167,18 +165,17 @@ jobs: testResultsFormat: "VSTest" mergeTestResults: true - task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4 - condition: and(succeededOrFailed(), eq(variables['CollectCoverage'], 'true')) + condition: and(succeededOrFailed(), eq(variables['CollectCoverage'], 'true'), eq(variables['coverage.collected'], 'true')) displayName: Generate Code Coverage Reports inputs: reports: $(Build.SourcesDirectory)\sdk\${{parameters.ServiceDirectory}}\**\coverage.cobertura.xml targetdir: $(Build.ArtifactStagingDirectory)\coverage - reporttypes: Cobertura;HtmlInline_AzurePipelines + reporttypes: Cobertura filefilters: +$(Build.SourcesDirectory)\sdk\${{parameters.ServiceDirectory}}\** verbosity: Verbose - task: PublishCodeCoverageResults@1 - condition: and(succeededOrFailed(), eq(variables['CollectCoverage'], 'true')) + condition: and(succeededOrFailed(), eq(variables['CollectCoverage'], 'true'), eq(variables['coverage.collected'], 'true')) displayName: Publish Code Coverage Reports inputs: codeCoverageTool: Cobertura summaryFileLocation: $(Build.ArtifactStagingDirectory)\coverage\Cobertura.xml - reportDirectory: $(Build.ArtifactStagingDirectory)\coverage