[FOLIO-1818] Sonar analysis "coverage on new code" for PRs of NPM-based repos not happening recently Created: 21/Feb/19  Updated: 03/Jun/20  Resolved: 28/Feb/19

Status: Closed
Project: FOLIO
Components: None
Affects versions: None
Fix versions: None

Type: Bug Priority: P3
Reporter: David Crossley Assignee: David Crossley
Resolution: Done Votes: 0
Labels: ci, platform-backlog
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original estimate: Not Specified

Sprint: Core: Platform - Sprint 58
Story Points: 2
Development Team: Core: Platform

 Description   

Sonar "coverage on new code" is not happening for pull requests, for NPM-based repositories.
See comment in slack#development on 20199221

It is happening okay for Maven-based repsitories.



 Comments   
Comment by David Crossley [ 21/Feb/19 ]

For example, https://github.com/folio-org/ui-orders/pull/266/checks
on the Checks tab shows "0.0% Coverage"
https://sonarcloud.io/component_measures?id=org.folio%3Aui-orders&pullRequest=266

Whereas Maven-based ones are okay.
For example, https://github.com/folio-org/mod-circulation/pull/191/checks
on the Checks tab shows "92.9% Coverage"
https://sonarcloud.io/component_measures?id=org.folio%3Amod-circulation&pullRequest=191

Comment by David Crossley [ 21/Feb/19 ]

Not sure yet if related to FOLIO-1763 Closed , which seems to be related to changes to Sonar around mid-January 2019.

Note that we cannot now look back to see when it last worked, as our SonarCloud reports are deleted after about one month.

Comment by David Crossley [ 22/Feb/19 ]

It is not related.

Investigation ...

SonarQube scan for NPM-based projects was added 20180925 and lcov reports being run on all builds.

Soon after the jenkins-pipeline-libs was expanded to (among other changes) have separate configuration for master, branch, and PRs.
https://github.com/folio-org/jenkins-pipeline-libs/pull/53 ( FOLIO-1407 Closed )

The PR arm of vars/sonarqubeScanNPM.groovy does not have the option:

"-Dsonar.javascript.lcov.reportPaths=${lcovPath}/lcov.info"

so no reports, only on branches and master.

John Malconian should that change be made to enable Sonar code coverage reports on PRs?

Comment by John Malconian [ 25/Feb/19 ]

David Crossley Yes, go ahead and try it on PRs.

Comment by David Crossley [ 26/Feb/19 ]

There is a PR here to test this:
https://github.com/folio-org/ui-orders/pull/275

Aliaksei Chumakou As asked there, would you please add a sensible test portion of new code.

Comment by Aliaksei Chumakou [ 26/Feb/19 ]

David Crossley Actually this might be connected with parsing code issue in SonarJS, here is the fix 11 days ago, to use babel parser instead of espree https://github.com/SonarSource/SonarJS/pull/1183/files

Comment by David Crossley [ 27/Feb/19 ]

Thanks Aliaksei for adding the test code.

Regarding that SonarJS update mentioned above. I reckon that that is a separate issue. I presume that you are referring to the messages that we see in our Jenkins output for the Sonar stage, regarding "espree".

Now i am not sure of this (John Malconian please correct) but i gather that we use https://github.com/SonarSource/sonar-scanner-jenkins (which may include that).

Comment by David Crossley [ 27/Feb/19 ]

Back to this FOLIO-1818 Closed . I needed to update my code in jenkins-pipeline-libs for a silly mistake.

There is a new PR that tests this: https://github.com/folio-org/ui-orders/pull/276
and hooray, it works.

The "new code coverage" summary is reported to the PR Checks tab, and the SonarCloud report is as expected for the PR build as well as the branch build.

So this FOLIO-1818 Closed is now "In code review" and this PR is ready to merge:
https://github.com/folio-org/jenkins-pipeline-libs/pull/59

Comment by David Crossley [ 28/Feb/19 ]

Closed.

After merging jenkins-pipeline-libs/pull/59 and restoring the Jenkinsfile in the test PR ui-orders/pull/276 now the Sonar new code coverage report is updated on the Checks tab.

Comment by Aliaksei Chumakou [ 28/Feb/19 ]

David Crossley Thanks a lot from all ui-modules teams!

Generated at Thu Feb 08 23:16:08 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d.