Two project monorepo shows two GH PR decorations but only one project changed

  • which versions are you using:
    • SonarQube 9.9 LTS Enterprise
    • gradle plugin: 4.0.0.2929
    • sonar-scanner: 5.0.1.3006
  • how is SonarQube deployed: Docker
  • what are you trying to achieve:
    Thanks in advance for your help. I have a two project mono repo with GitHub PR decoration. I’m trying to configure the projects so that when a change is made to just one SQ project the repository PR only gets one decoration. Currently the PR receives two decorations for a change that is specific to one project. The decoration for the project with no change shows no files changed.
    Other Info:
    • In my setup, one of the projects uses the gradle java plugin while the other uses the sonar-scanner binary.
    • The java project lives under src/
    • the sonar-scanner project (JS frontend) lives under ui/src.
    • In the above scenario, a change was made to the JS project (the PR decoration shows the correct modifications in SQ) but the PR decoration for the java app shows no changes.
  • what have you tried so far to achieve this:
    • I have followed the PR decoration instructions for GitHub and enabled the mono repo toggle on both SQ projects.
    • I have configured Source File Inclusions on each project to use the appropriate sources directory within SQ.
    • On the scanner side, the gradle plugin is configured to only use java sources and the sonar-project.properties has sonar.sources configured for the JS source directory

Any thoughts on other things to try to get this working would be appreciated.

sonar-project.properties

sonar.projectKey=app-ui
sonar.projectName=app-ui
sonar.sources=ui/src/
sonar.javascript.lcov.reportPaths=ui/coverage/lcov.info
sonar.sourceEncoding=UTF-8
sonar.coverage.exclusions=**/index.ts
sonar.exclusions=**/*.d.ts, \
**/*.test.*, \
**/*.scss, \
node_modules/**, \
dist/**, \
playwright/**, \
playwright-report/**

gradle configuration

sonar {
  properties {
    property 'sonar.projectKey', "app"
    property 'sonar.projectName', "app"
    property 'sonar.sources', "src/main/"
    property 'sonar.coverage.jacoco.xmlReportPaths', "build/jacoco/aggregated/jacoco.xml"
  }
}

Hey there.

This is expected if you are running two analyses against your monorepos (one for each project) when only project has changed.

You may want to look into ways to filter which actions run based on the path.

That makes sense. However, can you elaborate on what the mono repo flag in the DevOps Platform Integration does? The documentation seems to imply that my above use case should work as I expect it to.

Hey there.

This setting is an old setting related to Azure DevOps. As noted in the settings description:

Set to true if this project belongs to a monorepo. This enables better support for pull requests. This setting is currently only working for Azure DevOps repositories.

So it won’t apply here.

The currents state of Monorepo for support and SonarCloud can be found here, including instructions for configuring project(s) as a monorepo, if that isn’t already the case.