utPLSQL/utPLSQL-cli

How to import ut_coverage_sonar_reporter into sonarqube?

guicampos opened this issue · 12 comments

(a little edit)
Hello guys,
I have just generated a coverage report with

utplsql run -d  user/passwd@host:1521/mydb -source_path=sources -test_path=tests -f=ut_coverage_html_reporter -o=generic_html_coverage.html -c -f=ut_coverage_sonar_reporter -o=sonar_coverage.xml -f=ut_sonar_test_reporter     -o=sonar_test_results.xml --failure-exit-code=0

Everything seems to be ok, the test runned ok and now I have 3 files:
3,5K Jun 5 18:08 generic_html_coverage.html (and generic_html_coverage.html_assets)
169 Jun 5 18:08 sonar_coverage.xml
365 Jun 5 18:08 sonar_test_results.xml

I have a working sonarqube installed, and I have created a project there.

The question is: how do I import coverage.xml into my sonarqube project? I couldn't find how to do that in anywhere.

Thank you very much

Ok, after some research and struggling around, I was able to use sonar-scanner to try to scan my project.

Also after configuring the sonar-project.properties, now I have:

Caused by: You must install a plugin that supports the language 'plsql'

It happens that our sonarqube is community edition, and the SonarPLSQL is available only from Developer edition+.
Is there anyway to mitigate this?

Hi @guicampos

I'm glad you got part of the problem solved.
With Sonar on-prem you will need license for PL/SQL plugin I'm afraid.

If you're working on open-source however, sonarcloud.io is allowing for free analysis of PL/SQL code.
You might want to checkout this PR I did over the weekend to OraOpenSource/Logger#230 to see how it integrates with sonarcloud.

There is alternative plugin or PL/SQL for sonar analysis (PLSQL cop) - @PhilippSalvisberg can provide extra info
Also see:
https://www.salvis.com/blog/plsql-cop-for-sonarqube/
http://www.sonarplugins.com/plsqlcop

I'm not sure however if you're looking mainly for static code analysis or mainly for ability to publish code coverage and test results somewhere.

If its about coverage and test results, I would encourage to use Jenkins to run automated tests
you can run them on commit (if you're using version control), periodically (daily for example) or on demand.
The following reporters can help:

  • ut_junit_reporter
  • ut_cobertura_coverage_reporter

Jenkins or as well as other CI servers support Cobertura coverage standard as well as JUnit XML and can provide pretty good insight into test results and code coverage over time.

Hope this helps.

Hello, Thank you for your quick awnser!

I'm doing some tests to try to invent someway to make CI with Oracle Apex applications, along with those Apex applications' packages.
I'm a DBA, not a developer, I'm just making a research to help my dev team. So I don't have a clear final objective, just trying to go from 0 CI to something and learn something in between. hahaha

I'll take a look at the plsql-cop-for-sonaqube solution. Actually, I already use plsql-cop for sqldeveloper. I also have trained my dev team based on Trivadis PL/SQL coding guideline last year, so the are somewhat used to plsql-cop rules. That might be a good idea, indeed.

For now, I just tested this plugin:
https://github.com/felipebz/zpa

It's another foss sonarqube plugin. It works well, and it might be an option, but the catch is that you have to put sonar.language=plsqlopen in your sonar-project.properties.

Thank you, i'll post the plsql-cop-sonarqube results.

pesse commented

So great to hear you're encouraging your devs towards using automated self-tests and CI, @guicampos!
💪

AFAI know the following SonarQube plugins exists for PL/SQL:

Plugin sonar.language Notes
SonarPLSQL plsql Commercial product by SonarSource, based on SSLR
PL/SQL Cop for SonarQube plsqlcop Commercial product by Trivadis, based on Xtext
Z PL/SQL Analyzer (ZPA) plsqlopen Open source (LGPL v3) product developed by Felipe Zorzo, based on SSLR

@guicampos, if you are looking for a free solution, then ZPA is currently the only option.

If you need any help setting up jenkins deployment, join our slack. There are many people ready to share their knowledge :)

Click on a slack badge in utplsql readme on main utplsql project page

For now, I just tested this plugin:
https://github.com/felipebz/zpa

It's another foss sonarqube plugin. It works well, and it might be an option, but the catch is that you have to put sonar.language=plsqlopen in your sonar-project.properties.

Oh, thanks @guicampos! (full disclosure: I'm the developer)

I just wanted to clarify that the sonar.language parameter from SonarQube was deprecated a long time ago, it was even removed from SonarQube docs. It's not necessary. ;-)

@felipebz zpa plugin doesn't work with *.prc, here's the result when I tried to publish coverage report in sonarqube:
ERROR: Caused by: Line 3 of report refers to a file with an unknown language: source/test_proc/test_proc.prc

Any thoughts?

EDIT: NVM looks like a sonarqube community limitation https://jira.sonarsource.com/browse/SONAR-12014

@tlazaro-lululemon actually, you need to set the sonar.zpa.file.suffixes property to tell Sonarqube which extensions you're using for PL/SQL files. Adding the value prc to it will fix this error. Please see Supported configuration properties. In case of any question feel free to open an issue here.

Thank you @felipebz !