utPLSQL / utPLSQL-cli

Command line client for invoking utPLSQL
Apache License 2.0
40 stars 15 forks source link

How to import ut_coverage_sonar_reporter into sonarqube? #152

Closed guicampos closed 4 years ago

guicampos commented 5 years ago

(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

guicampos commented 5 years ago

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?

jgebal commented 5 years ago

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:

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.

guicampos commented 5 years ago

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 5 years ago

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

PhilippSalvisberg commented 5 years ago

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.

jgebal commented 5 years ago

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

guicampos commented 5 years ago

Cool, can you handle me the slack invitation link? Guilherme Campos

On Thu, Jun 6, 2019 at 4:36 PM Jacek Gębal notifications@github.com wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/utPLSQL/utPLSQL-cli/issues/152?email_source=notifications&email_token=AAFLMZ3B66XZX7PP2YZETRTPZFRKNA5CNFSM4HUHZFIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXD5XMI#issuecomment-499637169, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFLMZ2ITRQ3Q5QBVDE6RQDPZFRKNANCNFSM4HUHZFIA .

jgebal commented 5 years ago

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

felipebz commented 5 years ago

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. ;-)

tplazaro commented 4 years ago

@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

felipebz commented 4 years ago

@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.

tplazaro commented 4 years ago

Thank you @felipebz !