I have a monorepo in github with several python projects in subfolders. I tried follow the information in Monorepo Support | SonarCloud Docs but there is some information I’m struggling to figure out.
I created 8 projects in SonarCloud using the “monorepo” option as described in the document. After that the projects all ask to configure analysis. I followed the github Actions option, but not sure exactly how to do it.
It seems to need the sonar-project.properties in the root of the repo, but that makes me specify a single project and not the sub projects within the monorepo.
I also created the .github/workflows/build.yml and setup the path to one of the subprojects. I’m guessing I would create multiple .yml files, one for each project I want to scan.
Can anyone clarify what I’m missing to get the multiple projects in the monorepo to show up with the correct analysis for their subfolder?
Thanks Ann. I believe I tried that yesterday, but it didnt seem to find anything. I think Github requires the yml files to be in the root of the project. I’ll try again today to see if maybe I made a mistake when I tried before.
And yes, each project has its own individual directory within the repository with no crossing between project references.
I’m not really sure. Sorry I’m a beginner with SonarCloud. I have a repo in github with several sub-projects. I followed the documents when creating the project in SonarCloud, which had me create a build.yml and sonar-project.properties file. I just created them as stated in the web site.
I’m guessing I need to specify a location somewhere in the build.yml? The documentation for setting up a monorepo is very sparse, so I’m not really sure what to look for.
I found I need to put the build.yml in the root of the repo (not project) since github is looking for them there.
.github/workflows/build-testproject.yml
build-testproject.yml for one of the projects looks like
name: Scan Test Project
on:
push:
branches:
- main
paths:
- 'lambdas/test/**'
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Ah, looking back at your message, I finally realized, I need to add this to the build.yml to set the projectBaseDir. This really should be added to the monorepo support docs, since its a critical setting. Without that it won’t work.
Hi yes can I echo Mike’s comments, I’m new to all this and have had a nightmare today trying to get a monorepo to work (still isn’t but I think I’m getting there). The docs page and examples are hopeless, I have had to do a ton of web searches to try to work this out. Thanks