Sonar more rigorous on critical issues

First of all thanks to @tmueller, @sashrika, @yousefhamza and Tanay Abhra who contributed code to TRUNK-4613 and all reviewers involved! Sonar reports no blocker and critical issues in OpenMRS core as of now.

We can move the bar a bit higher in keeping our code in good shape. We will now fail OpenMRS core build whenever blocker or critical issues are introduced.

If Bamboo turns red after your commit to openmrs-core, open up the build in Bamboo and if no tests are failing, it is most likely due to sonar issues. You can either look them up opening sonar reports at the bottom of the build page in shared artifacts or by going to https://ci.openmrs.org/sonar directly. If you open up a specific issue in Sonar it will give you instructions on how to fix it. If in doubt, just ask on IRC or here.

2 Likes

@raff, if Sonar can make the build fail, couldnā€™t it also show up as the reason for failure? The ā€œif you donā€™t see a reason why the build is failing, look at Xā€ approach sounds less than ideal. Ideally, the build will fail with the message ā€œSonar test X failing. See this url for more detail.ā€ At a minimum, the build report/log for the failed build should say ā€œFailed Sonar tests. See https://ci.openmrs.org/sonar for details.ā€

The build log actually says new issues found and lists the number of issues, but it does not say what is the URL of our sonar instance.

We experimented some time ago with customizing the e-mail template that is used by Bamboo when build is failing due to Sonar issues, but then our Bamboo got upgraded and templates were lost. @cintiadr, is there any easier way to do that in the current Bamboo version?

Iā€™ve never modified the template of emails, but by documentation https://confluence.atlassian.com/display/BAMBOO/Modifying+notification+templates tells me itā€™s in Bamboo home directory, so the upgrade wasnā€™t supposed to affect it at all. I can see we have a ā€˜templates/notification-templates/BuildCompletedHtmlEmail.ftlā€™ file there, but I cannot see any notifications https://ci.openmrs.org/chain/admin/config/defaultChainNotification.action?buildKey=SON-OPENMRSCOREMASTER set for the sonar build. I would expect it to just work ā„¢.

I donā€™t have experience with the Sonar itself or the Bamboo solar plugin (apparently there are two https://marketplace.atlassian.com/search?application=bamboo&category=&cost=&hosting=&marketingLabel=&q=sonar available, and we are using the one from Mibex), but looks like none of them adds a result (success or failure) as a test (it doesnā€™t appear in the ā€˜Testā€™ tab).

If thereā€™s a way to generate a junit format file, thereā€™s a JUnit parser task in Bamboo. Itā€™s usually the simplest way of adding a ā€˜testā€™ to Bamboo.

An intelligible message in the build log would be most helpful. Are we using the Build Breaker? While thereā€™s an old ticket complaining about lack of useful output (SONARPLUGINS-1968), the code appears to log alert text.

Thanks Cintia! Notifications are indeed disabled now. I will look into that. The hint about generating a junit format file sounds interesting too.

@burke, yes we are using the Build Breaker plugin.

Sonar reports 39 critical issues https://ci.openmrs.org/sonar/drilldown/issues/org.openmrs:openmrs?severity=CRITICAL

1 Like

Thatā€™s correct Lluis. We had a sonar build failing due to Java 8 configuration issue and once I fixed it, sonar reported 39 new critical issues, which need to be addressed. I tweaked the build to fail if any new issues are added, but pass for existing issues until they are fixed.

Notifications are enabled and e-mails will go to committers if they break the sonar build.

1 Like