Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to report code coverage in Github Pull Requests using Sonar Github plugin

I have SonarQube server 5.6 and I am using Github. I have done the integration to setup Sonar Github plugin but I fail to understand whether this should report if the new code does not meet the code coverage threshold setup in the Quality Gate.

In the Quality Gate I have defined an error to be raised unless there is more than 75% code coverage for the new code that is being introduced by a Pull Request.

  1. Should the Sonar Github plugin report an issue (comment) in Github pull request if the new code added does not meet the Quality Gate metric that I setup?
  2. Is there any way to mark in Github Pull Requests if the new code trying to be merged does not meet the coverage expectations?

Thanks!

like image 848
Marius Ioana Avatar asked Apr 21 '17 15:04

Marius Ioana


People also ask

How do I show code coverage in Sonar?

xml file, we'll run mvn clean install to build our project. Then we'll start the SonarQube server before running the command mvn sonar:sonar. Once this command runs successfully, it will give us a link to the dashboard of our project's code coverage report: Notice that it creates a file named jacoco.

Is sonar a code coverage tool?

SonarQube itself does not calculate coverage. To include coverage results in your analysis, you must set up a third-party coverage tool and configure SonarQube to import the results produced by that tool. Below, you'll find guidelines and resources, as well as language- and tool-specific analysis parameters.


1 Answers

Pull request analysis cannot currently raise all types of issues. Specifically it cannot raise issues related to metrics because those are consolidated on the server side during analysis report processing and in a Pull Request analysis the analysis report is by design never submitted to the server.

EDIT The PR analysis which is offered as part of the Developer Edition($) does both decorate the PR in the provider (e.g. GitHub) and show the PR on the server. However, metric-related issues still don't show up in this enhanced analysis.

like image 75
G. Ann - SonarSource Team Avatar answered Oct 02 '22 23:10

G. Ann - SonarSource Team