Code Monkey home page Code Monkey logo

azure-pipelines-coveragepublisher's Introduction

Build Status

azure-pipelines-coveragepublisher

Library for publishing coverage files in a build pipeline. This library currently integrates with ReportGenerator.Core for parsing supported coverage files and creating HTML reports. This library shall be used for all future coverage publishing needs.

Usage

Core library for coverage publisher is built for .netstandard 2.0 and has console wrappers for both netcore2.0 and net461

Invoking

# Simple invocation
dotnet CoveragePublisher.Console.dll /path/to/jacoco.xml

# Invocation with multiple files and/or formats.
dotnet CoveragePublisher.Console.dll /path/to/jacoco.xml /path/to/cobertura.xml

CLI Options

Option Description
--reportDirectory (Default: "") Path where html report will be generated.
--sourceDirectory (Default: "") List of source directories separated by ';'.
--timeout (Default: 120) Timeout for CoveragePublisher in seconds.
--noTelemetry (Default: false) Disable telemetry data collection.
--help Display this help screen.

Build & Test

The source can be build through both Visual Studio and dotnet cli.

# Build
azure-pipelines-coveragepublisher/src$ dotnet build

# Test
azure-pipelines-coveragepublisher/src$ dotnet test

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

To turn telemetry off for coverage publisher use the --noTelemetry cli option.

azure-pipelines-coveragepublisher's People

Contributors

acesiddhu avatar chandrashritii avatar danielpalme avatar jakubch1 avatar karanjitsingh avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar p00j4 avatar rasunkar avatar vinayakmsft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-pipelines-coveragepublisher's Issues

Please update ReportGenerator to the latest version

In our Azure DevOps pipeline the coverage report is generated and published by the PublishCodeCoverageResults@1 task from a cobertura.xml file. Unfortunately the generated html report is not accurate as it does not visualize yield return rows, async methods and possibly others as covered. According to the cobertura.xml file they are covered. After investigation I found that it could be a bug in ReportGenerator that has been fixed meanwhile as the latest version (5.1.5 at the time of writing) shows these parts properly.

Publisher makes 2 HTML reports on azure with PublishCodeCoverageResults@2. This makes it slow with large coverage data.

I found that coverage publisher has unexpected behaviour in my case. My log at azuredevops PublishCodeCoverageResults@2 is following:

...
Found 1 result(s) matching pattern: F:\agent1\_work\2\TestResults\*\*.cobertura.xml
F:\agent1\_work\2\TestResults\3e4306b4-f889-4e26-91b6-ccef258d7ca8\unittest.mytest.cobertura.xml
...
##[debug]ReportGeneratorTool.ParseCoverageFiles: Parsing coverage files.
...
2024-01-12T18:27:17: Finished parsing 'F:\agent1\_work\2\TestResults\3e4306b4-f889-4e26-91b6-ccef258d7ca8\unittest.mytest.cobertura.xml' 1/1
2024-01-12T18:27:17: Parsing of 1 files completed
2024-01-12T18:27:17: Starting merging result 1
2024-01-12T18:27:17: Finished merging result 1
##[debug]ReportGeneratorTool.CreateHTMLReportFromParserResult: Creating HTML report.
2024-01-12T18:27:18: Initializing report builders for report types: HtmlInline_AzurePipelines
2024-01-12T18:27:18: Analyzing 249 classes
...
##[debug]Parser.GenerateHTMLReport: Creating summary file directory: F:\agent1\_work\_temp\ff13e3f5-e245-48a5-ab0c-07e0e60a6528\Summary_ec27501f
##[debug]Parser.GenerateHTMLReport: Copying summary file F:\agent1\_work\2\TestResults\3e4306b4-f889-4e26-91b6-ccef258d7ca8\unittest.mytest.cobertura.xml
##[debug]PERF : Parser.ReportGeneration : took 7079.4571 ms.
##[debug]ReportGeneratorTool.GetFileCoverageInfos: Generating file coverage info from coverage files.
##[debug]ReportGeneratorTool.CreateHTMLReportFromParserResult: Creating HTML report.
2024-01-12T18:27:24: Initializing report builders for report types: HtmlInline_AzurePipelines
2024-01-12T18:27:24: Analyzing 249 classes
...
2024-01-12T18:27:28: Creating summary
2024-01-12T18:27:28: Writing report file 'F:\agent1\_work\_temp\ff13e3f5-e245-48a5-ab0c-07e0e60a6528\index.html'
##[debug]Parser.GenerateHTMLReport: Creating summary file directory: F:\agent1\_work\_temp\ff13e3f5-e245-48a5-ab0c-07e0e60a6528\Summary_fb1344ea
##[debug]Parser.GenerateHTMLReport: Copying summary file F:\agent1\_work\2\TestResults\3e4306b4-f889-4e26-91b6-ccef258d7ca8\unittest.mytest.cobertura.xml
##[debug]PERF : Parser.ReportGeneration : took 4310.1144 ms.
##[debug]ReportGeneratorTool.GetCoverageSummary: Generating coverage summary for the coverage files.
##[debug]Publishing code coverage summary supported
Publishing coverage summary data.
...

As a result I have 2 summary folders published with the same coverage files.

I guess the first call of GenerateHTMLReport is redundant and should not be called.

Version:

Task         : Publish code coverage results v2
Description  : Publish any of the code coverage results from a build
Version      : 2.231.0

Add support for Branch coverage

Why is only line coverage published?
After parsing a cobertura.xml for example there is totalBranches and coveredBranches. These could be added in ReportGeneratorTool.GetCoverageSummary(). The information are there, why don't you send them?

Chart Code Coverage % over Time

Does anyone know of a resource or tool that integrates with ReportGenerator output to chart (overall) code coverage over time for a pipeline, as opposed to calculating it for a given build in a pipeline?

Query: does it supports latest security supported .NET core version?

In my pipeline, I have started getting this message and hence want to move to supported version to .NET 7 or 6 as per https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core
/Users/runner/.dotnet/sdk/7.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The target framework 'netcoreapp2.1' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/dotnet-core-support for more information about the support policy. [/Users/runner/CoveragePublisher/azure-pipelines-coveragepublisher/src/CoveragePublisher.Console/CoveragePublisher.Console.csproj::TargetFramework=netcoreapp2.1]

The readme and yml both mentions .NET 2.0 https://github.com/microsoft/azure-pipelines-coveragepublisher#usage

Query: Code Coverage Tab: how to force link original Cobertura ReportGenerator Report

In my pipeline, I have coverage.xml of cobertura style using reportgenerator
which has hyperlinks to visualize the missing coverage in actual code files.

Example:
image
image

image
image

Problem

When I enable diff coverage using CoveragePublisher and azurepipelines-coverage.yml file. I start seeing a different report which is not useful for my case because it doesn't have the navigation feature to the visuals.

image

In both the cases, I'm explicitly publishing at the end and also the right Html with index.html are produced properly (I can find them in the artifacts)
Expecting the same index.html to be linked on the Code Coverage tab. What am I missing? Because it works as expected without using CoveragePublisher (this repo's diff coverage)

image

Possible reason: I'm guessing somewhere call to https://github.com/microsoft/azure-pipelines-coveragepublisher/blob/master/src/CoveragePublisher/Publishers/DefaultPublisher/HtmlReportPublisher.cs is overriding the behavior.

How can I make the Code Coverage pick the index.html from the Code Coverage_Report folder?

Expected

  1. Desire to get the ReporterGenerator report (as per the first screenshot) after enabling codeocveragepublsher's diff coverage comment on.

  2. Also a query:
    In general, how doe the "Code Coverage" tab work? which file and which path it tries to look at? And what settings can change it's behaviour?

PS. With Visuals I mean, the highlights on actual code with what's not covered or covered. Example below are the screenshots I get on clicking on any of the classname in the first desired report.
image
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.