Angular monorepo using Nwrl/Nx workspace to selectively test only the projects that had code changes. Then upload those reports to SonarQube in a Github action/workflow.
Which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension):
- SonarQube 8.8 build 42792 - Developer Edition
- sonarqube-scanner npm package
- jest-sonar 0.2.4 npm package
- @nwrl/jest 10.3.2 npm package
What are you trying to achieve:
- I’m trying to understand how best to report results (currently using
sonar-project.propertiesfile) for only those projects that were affected by a change. Nwrl/nx allows you to test, lint, build, etc. only those projects that had altered code somewhere in its dependency tree. The report paths don’t allow wildcards, and Sonar will error if it can’t find a report file that I said should be there (based on that properties file).
- The analysis should run on PR branches and when merges occur into main. This is done via Github actions/workflow
What have you tried so far to achieve this:
- For the time being, I am not utilized the
nx affectedfunctionality, so all of the tests run. I also hard coded the paths to each of the apps/libraries in the
sonar-project.propertiesfile. To get selective tests running with Sonar, I guess I might be able to find a way to determine which projects in the monorepo were tested, determine the report path(s), and then pass those via commandline to Sonarqube. Hopefully there is a smoother way to do that or avoid doing that?
Any help/tips/etc. would be appreciated