-
-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for decorating Pull Requests #30
Conversation
LGTM @mc1arke When do you expect that this is merged? Are there still things that you want to refactor or add (tests)? I would like to add the Bitbucket Server integration including comments on file level. |
@majorvin Changed the way that the overall comment is built to use a builder as this was very hard to read. I also had to rework PostAnalysisIssueVisitor a bit so that we can keep the path to the analysed file as this is required for a file comment. @mc1arke can we add the changes I made to this PR? |
@majorvin What tests are failing? When built with Java 9 or above I've got the
@4n4n4s If you think you're code is ready for review/merge then please raise a Pull Request targeting the |
@mc1arke thx for your reply. I do agree. It should not make too many problems to update the classes I touched with your changes. When do you think that your changes will be ready for pushing it to this PR? I will create the PR targeting this branch hopefully today. |
Will you plan to support Azure DevOps Server PR Decoration? |
@tisoft thanks for the contribution. I've had limited time for properly being involved in these changes in the past month but hope to get back into it this week. I'll take a look at your changes as-soon-as-possible and give you any feedback. As you've suggested, I've refactored my initial Pull Request to split up some of the generation and gathering steps and the actual decoration step which should simplify what needs implemented in each case. I'll probably raise the changes under another branch so @4n4n4s can rebase cleanly rather than dealing with re-writing history against the current branch. @coreinsane I've never use Azure DevOps and am happy to look at supporting it, but would need the community to provide support in testing it and confirming any usage patterns that need to be followed. |
@mc1arke Tried to run the branch with additional parameters as
But getting |
@rverma-nikiai I had the same behavior if the sonar.branch.name parameter is set while trying to do pull request analysis. |
Wondering what is a good way to debug sonarqube plugins. I tried to add @tisoft Did it work if you stop passing sonar.branch.name? |
Yes that helped. |
Removing that did regitered the pullrequest decorator. But now getting exception as |
Found that above issue was cause of an empty line at EOF. Now the scan run successfully but I don't see anything in my github PR. |
You're more likely to want
Other classes are shared across the different components in the infrastructure so debugging them will depend on what feature you're trying to use/test. |
It will be nice to have coverage analyses result in comments on PR. What do you think about? |
I tried to test the PR decoration (I build manually your code) to validate this PR and the behaviour, but without any success. My conclusion is that I did not pushed parameters from my maven command to Sonar. Below my
In To move forward, I force the parameter So, I think I have miss something somewhere, Do you have an idea? Information: I test with Sonar 7.9. |
You have to set these values on SonarQube side in your project settings. It would be nice to set these values with the maven command. See also: https://docs.sonarqube.org/latest/analysis/pull-request/ |
@mc1arke Will you plan to rebase/merge this PR or merge other PRs to current branch for nearby future? |
Thanks, it works well for me. I'll continue to test with more cases. |
f053ed7
to
3eb5def
Compare
3eb5def
to
e808a9d
Compare
The existing method of adding comments to methods to indicate what version of Sonarqube the method is supporting is difficult to maintain and prevents external developers from easily working with Sonarqube updates. Adding a new `SonarqubeCompatibility` interface with extensions for each major and minor Sonarqube version that removes any methods, as well as switching existing methods to use these new interfaces, allows for the code-base to consistently compile against different Sonarqube versions, and indicates why any out-dated methods are being retained. This change also corrects tests that incorrectly depended on interfaces or methods to perform a test, where an alternative approach could be used for a more reliable and maintainable result.
Provides the interfaces and models to allow collection of metrics and issues for publishing to pull requests. To allow consistent rendering of information across different version control providers, an `AnalysisDetails` class exposing the collected metrics, and a pre-built message containing a summary of the analysis results. To allows for different providers using different formats of status messages, the status message is produced as a syntax tree, with each Pull Request Provider implementation providing a formatter to convert the tree to a suitable output type. A default Markdown formatter has been included to support this. The images used for portraying the measures in the decoration have been copied unmodified from the sonarqube/sonarcloud-github-static-resources repository and, as no license is set on this repository or referenced in any of the files, these are presumed to be in the public domain so available for use here.
e808a9d
to
ce99b08
Compare
Uses the Github rest APIs to perform application authentication, and the GraphQL APIs to create a 'Check Run' providing the overall summary of the scan, and individual annotations of issues within each file. No attempt is made to remove old runs/annotations given Github seems to manage this when a new run is generated by the same application. The configuration of Sonarqube to allow this decoration aim to match those provided in the documentation for SonarQube 8.0.
Use Bitbucket REST interfaces to apply comments to Pull Requests. Where possible, any existing comments are removed prior to adding comments to prevent any duplication, and properties have been added to control whether commenting and clean-up of comments is enabled.
Uses Gitlab's rest API to create conversations/threads on a merge request containing annotations for each issue discovered by SonarQube, and provides a message on the merge request containing the scan summary.
This change introduces the APIs and components to allow the collection of issues and metrics during analysis, and an initial implementation for decorating requests on Github using these metrics. The Github implementation uses v4 of the Github API to create the 'check run' with the analysis results, but v3 of the API to acquire the relevant application authentication tokens since application authentication cannot currently be created/retrieved through the v4 API.
The provided implementation currently only supports the same level of reporting as provided by the official SonarQube branch decoration, but without including any images in the summary, and the configuration properties match those in the official documentation for setting up SonarQube for application based authentication against Github.