Monorepo nx - 1 quality gate per app

I have a monorepo with 3 different apps inside. these apps are under ./apps

I followed the documentation (Monorepo Support | SonarCloud Docs) but is still not clear for me how this works.

So if I understood correctly, we can setup a specific quality gate for each app, and that I managed to create. I have now 3 project keys one for each app.

Following the github actions tutorial it have to create a ./github/workflows/build.yml file and thats fine, but then it ask me to create one on the root folder

The problem is that I have 3 different apps, and only one file, so how can I match the specific app with the specific project key?

Thank you in advance!

Hey there.

You’ll need to have a different file for each app, and then set the base directory for each separate scan. Take a look at the example here:

Hi Colin ty for the quick reply!

ok I should setup in the github action file the 3 different projectBaseDir but how they relate with each separate quality gates? there is no link

name , uses , GITHUB_TOKEN and SONAR_TOKEN are all the same

The that you place in the root directory of each app (the base directory you are configuring for the scan, not the whole repo) will contain a file each with a different project key.

ok got it. so this means that now if there is a PR to a specific app, only that quality gate is going to run right?

what happens then if a developer also updated some root files? that are not inside apps/ folder? will sonar still run? no right…

That really depends on how you’ve configured your build – when you change the code in one app, do all of your apps build?

If so – then yes, scans will run for all three projects and a Quality Gate will be reported for each application. However, if no code changed in the other apps, those Quality Gates shouldn’t change.

It depends on how you’ve configured your actions. There are features of GitHub actions to limit runs to when certain files change.

so if I configure my action with with: projectBaseDir: apps/app-1/ then if I understood correctly only the contents of this folder will be taken in consideration right? and then inside that folder I have the that then will inform sonar cloud which quality gate to use.

maybe apart from those 3 steps (actions) i need to create a default one without projectBaseDir and then configure my monorepo again with a root quality gate excluding the apps/ folder

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.