MicrosoftPremier / VstsExtensions

Documentation and issue tracking for Microsoft Premier Services Visual Studio Team Services Extensions
MIT License
59 stars 14 forks source link

BQC - Waits indefinitely with the recurring message "Waiting for code coverage data..." #96

Closed sdg002 closed 4 years ago

sdg002 commented 4 years ago

Snapshot of from the log

{"id":"5083","url":"https://dev.azure.com/CorResilience/_apis/build/Builds/5083"},"deltaBuild":null} 2020-05-27T17:40:31.8975676Z ##[debug]------------------ END RAW DATA ------------------ 2020-05-27T17:40:31.8975885Z Waiting for code coverage data... 2020-05-27T17:40:34.2431324Z ##[debug]-------------------- RAW DATA -------------------- 2020-05-27T17:40:34.2432371Z ##[debug]buildCoverageSummary: 2020-05-27T17:40:34.2433094Z ##[debug]{"coverageData":[],"build":{"id":"5083","url":"https://dev.azure.com/CorResilience/_apis/build/Builds/5083"},"deltaBuild":null} 2020-05-27T17:40:34.2434308Z ##[debug]------------------ END RAW DATA ------------------ 2020-05-27T17:40:34.2434726Z Waiting for code coverage data... 2020-05-27T17:40:36.5810992Z ##[debug]-------------------- RAW DATA -------------------- 2020-05-27T17:40:36.5811648Z ##[debug]buildCoverageSummary: 2020-05-27T17:40:36.5812057Z ##[debug]{"coverageData":[],"build":{"id":"5083","url":"https://dev.azure.com/CorResilience/_apis/build/Builds/5083"},"deltaBuild":null} 2020-05-27T17:40:36.5812506Z ##[debug]------------------ END RAW DATA ------------------ 2020-05-27T17:40:36.5812712Z Waiting for code coverage data... 2020-05-27T17:40:37.4370691Z ##[error]The task has timed out. 2020-05-27T17:40:37.4373265Z ##[section]Finishing: Check build quality

YAML Task

steps:
- task: mspremier.BuildQualityChecks.QualityChecks-task.BuildQualityChecks@6
  displayName: 'Check build quality'
  inputs:
    checkCoverage: true
    coverageFailOption: fixed
    coverageType: lines
    coverageThreshold: 80
  timeoutInMinutes: 3
ReneSchumacher commented 4 years ago

Hi @sdg002,

did you publish code coverage data in your pipeline? How are you creating the coverage data? Are you using the Visual Studio Test task or another task?

René

sdg002 commented 4 years ago

Hi @ReneSchumacher Thanks for the quick response. We are using MSTEST. Here is a snapshot from our YML.

    - script: |        
        dotnet test --logger "trx;LogFileName=Test-Results.trx" "$(System.DefaultWorkingDirectory)/CorResilience.Ingestion.Garmin.Api.Tests" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/coverage1.cobertura.xml
      displayName: Run Unit Tests

- task: PublishTestResults@2
      inputs:
        testResultsFormat: 'VSTest'
        testResultsFiles: '**/Test-*.trx'
        searchFolder: '$(System.DefaultWorkingDirectory)/'

    - task: reportgenerator@4
      displayName: ReportGenerator
      inputs:
        reports: '$(Build.SourcesDirectory)/TestResults/Coverage/*.xml'
        targetdir: '$(Build.SourcesDirectory)/TestResults/Coverage'
        sourcedirs: '$(Build.SourcesDirectory)'

    - task: PublishCodeCoverageResults@1
      displayName: 'Publish code coverage results'
      inputs:
        codeCoverageTool: Cobertura
        summaryFileLocation: '$(Build.SourcesDirectory)/TestResults/Coverage/*cobertura.xml'
        reportDirectory: '$(Build.SourcesDirectory)/TestResults/Coverage'        

    - task: BuildQualityChecks@6
      inputs:
        checkCoverage: true
        coverageFailOption: 'fixed'
        coverageType: 'lines'
        coverageThreshold: '80'

    - task: DotNetCoreCLI@2
      inputs:
        command: publish
        arguments: '--configuration Release /p:Version=$(MajorVersion).$(MinorVersion).$(PatchNumber) /p:FileVersion=$(Build.BuildNumber) --output publish_output'
        projects: "$(System.DefaultWorkingDirectory)/CorResilience.Ingestion.Garmin.Api/*.csproj"
        publishWebProjects: false
        modifyOutputPath: true
        zipAfterPublish: false
      displayName: Publish Function App
sdg002 commented 4 years ago

Screen capture image

ReneSchumacher commented 4 years ago

Can you make sure that you see code coverage values in the build summary? And/or could you post the log of the PublishCodeCoverageResult task?

sdg002 commented 4 years ago

8_Publish code coverage results.zip

The log from the PublishCodeCoverageResult attached.

Please, could you guide me as to how I can access the actual code coverage results from this step?

Thank you.

sdg002 commented 4 years ago

Cobertura.zip The code coverage file attached. Nearly empty!

sdg002 commented 4 years ago

Code Coverage Report_5086.zip The complete ZIP from Azure Devops. Empty!

sdg002 commented 4 years ago

Looks like there is a problem with the generation of the Code Coverage report.

This is from the Run Unit Tests log file

2020-05-27T18:24:24.6588918Z D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj : warning NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 11.0.2) but version Newtonsoft.Json 12.0.2 was resolved.
2020-05-27T18:24:24.6592270Z D:\a\1\s\CorResilience.Ingestion.Garmin.Api\CorResilience.Ingestion.Garmin.Api.csproj : warning NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 11.0.2) but version Newtonsoft.Json 12.0.2 was resolved. [D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj]
2020-05-27T18:24:25.8321535Z D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj : warning NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 11.0.2) but version Newtonsoft.Json 12.0.2 was resolved.
2020-05-27T18:24:26.7202218Z D:\a\1\s\CorResilience.Ingestion.Garmin.Api\CorResilience.Ingestion.Garmin.Api.csproj : warning NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.29 requires Newtonsoft.Json (= 11.0.2) but version Newtonsoft.Json 12.0.2 was resolved.
2020-05-27T18:24:31.0574189Z C:\Users\VssAdministrator\.nuget\packages\coverlet.msbuild\2.6.3\build\coverlet.msbuild.targets(24,5): warning : [coverlet] Unable to instrument module: D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\bin\Debug\netcoreapp2.1\CorResilience.Ingestion.Garmin.Api.dll because : The type initializer for 'Coverlet.Core.Instrumentation.NetstandardAwareAssemblyResolver' threw an exception. [D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj]
2020-05-27T18:24:31.0641352Z C:\Users\VssAdministrator\.nuget\packages\coverlet.msbuild\2.6.3\build\coverlet.msbuild.targets(24,5): warning : [coverlet] Unable to instrument module: D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\bin\Debug\netcoreapp2.1\CorResilience.Ingestion.Garmin.Core.dll because : The type initializer for 'Coverlet.Core.Instrumentation.NetstandardAwareAssemblyResolver' threw an exception. [D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj]
2020-05-27T18:24:31.0684045Z C:\Users\VssAdministrator\.nuget\packages\coverlet.msbuild\2.6.3\build\coverlet.msbuild.targets(24,5): warning : [coverlet] Unable to instrument module: D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\bin\Debug\netcoreapp2.1\CorResilience.Ingestion.Garmin.Infrastructure.dll because : The type initializer for 'Coverlet.Core.Instrumentation.NetstandardAwareAssemblyResolver' threw an exception. [D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\CorResilience.Ingestion.Garmin.Api.Tests.csproj]
2020-05-27T18:24:31.4220600Z Test run for D:\a\1\s\CorResilience.Ingestion.Garmin.Api.Tests\bin\Debug\netcoreapp2.1\CorResilience.Ingestion.Garmin.Api.Tests.dll(.NETCoreApp,Version=v2.1)
sdg002 commented 4 years ago

Problem solved. Updated NUGET reference and code coverage information was generated correctly.

PackageReference Include="coverlet.msbuild" Version="2.8.1"

Thank you.

ReneSchumacher commented 4 years ago

Great that you could resolve the issue and thanks for letting us know. I'm closing the issue now but please feel free to open a new one if you run into any other problems with t he task.