- ALM used: GitHub
- CI system used: Circle CI
- Languages of the repository: Ruby
- Private project
Hi everyone, I’m trying to set up SonarCloud analysis with CircleCI, but I’m running into two issues. I haven’t found a solution by searching past issues, and the documentation seems to be missing some details.
First, my repo’s specs run in parallel. I would like SonarCloud to run only once after the specs are complete, but it runs for each parallel instance.
Second, I would like a coverage report, and I have confirmed that it produces a coverage report using simplecov and uploads the artifacts (again, once for each parallel instance). However, when I look at my analysis, it claims that extra steps are still needed to set up coverage (indicating that the steps I took were insufficient).
Here is my CircleCI config, relevant portions only:
jobs:
rails-lint:
# Omitted for brevity
rspec:
executor: rails
parallelism: 4
working_directory: ~/my_working_dir
steps:
- setup-project # This is a custom command that handles checkout, npm, bundle, etc
- run: |
bundle exec rspec --profile 10 \
--format RspecJunitFormatter \
--out test_results/rspec.xml \
--format progress \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
- store_test_results:
path: test_results
- store_artifacts:
path: coverage
# I can confirm that the coverage artifacts are uploaded, once for each parallel run
- sonarcloud/scan
# This runs four times due to parallelism, but I would like it to only run once
db:
# Omitted for brevity
workflows:
test:
when: << pipeline.parameters.run-rails-job >> # This is the parameter that will be updated by the path-filtering orb
jobs:
- rspec:
context: SonarCloud
- db
- rails-lint
And here is my sonar-project.properties:
sonar.projectKey=my_project_key
sonar.organization=my_org
sonar.ruby.coverage.reportPaths=coverage/coverage.json
Is there any way for me to merge my parallel coverage reports and then run a sonar scan on the code base with the merged results?