MicrosoftPremier / VstsExtensions

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

I see coverage of 46% in the code coverage tab in summary of the pipeline in the task it shows 0% and failing #221

Closed kiranve closed 1 year ago

kiranve commented 1 year ago

SystemVssConnection exists true Using IdentifierJobResolver Validating code coverage policy... Successfully read code coverage data from build. Evaluating coverage data from 1 filtered code coverage data sets... Total lines: 1028 Covered lines: 0 Code Coverage (%): 0 [ERROR] The code coverage value (0%, 0 lines) is lower than the minimum value (10%)!

[error]The code coverage value (0%, 0 lines) is lower than the minimum value (10%)!

[error]At least one build quality policy was violated. See Build Quality Checks section for more details.

Finishing: Check build quality

Showing like this in the task Coverage

ReneSchumacher commented 1 year ago

Hi @kiranve,

thanks for reporting this. Could you please run the pipeline again with the variables System.Debug and BQC.LogRawData set to true and send the task log to PSGerExtSupport@microsoft.com? Please check the log for any sensitive data before sending it over (it does contain organization and project names).

Currently, Azure DevOps does not support merging multiple 3rd party coverage reports (like Cobertura). If you publish multiple reports, only data from the last published report is used in the API. Report Generator, the tool we use to generate the Code Coverage tab content, does merge multiple Cobertura files (in your screenshot it explicitly says "MultiReport (5x Cobertura)".

You can quickly check if this is indeed the root cause by calling the following URL in the browser (replace organization, project, and buildId accordingly):

https://dev.azure.com/{organization}/{project}/_apis/test/codecoverage?buildId={buildId}&flags=7

The resulting JSON data shows the coverage summary that is used by BQC and it should contain the same data that is reported by BQC.

ReneSchumacher commented 1 year ago

Hi again,

I just looked through your log file and the reason really seems to be the missing merge of several Cobertura files. The log file is showing this API response from Azure DevOps:

{
    "coverageData": [
        {
            "coverageStats": [
                {
                    "label": "Branches",
                    "position": 6,
                    "total": 288,
                    "covered": 0,
                    "isDeltaAvailable": true,
                    "delta": 0
                },
                {
                    "label": "Lines",
                    "position": 4,
                    "total": 1028,
                    "covered": 0,
                    "isDeltaAvailable": true,
                    "delta": 0
                }
            ],
            "buildPlatform": "",
            "buildFlavor": ""
        }
    ],
    "build": {
        "id": "211309",
        "url": "redacted"
    },
    "deltaBuild": null,
    "status": 2
}

You can see that is reports zero of 1028 lines covered. Since your summary page shows 1048 uncovered and 1960 coverable lines, this indicates that the API only sees a portion of your coverage data (most likely the last coverage report that was published).

The only workaround for now would be to merge the Cobertura reports on the agent before you publish the merged report. I know that ReportGenerator can do this.

ReneSchumacher commented 1 year ago

I'm closing this issue now since there hasn't been any additional feedback and there is currently no way of solving this in the task.