ci(sonarcloud): add SonarCloud analysis with Quality Gate on PRs - #22
Merged
Merged
Conversation
… PRs - New .github/workflows/sonarcloud.yml: dotnet-sonarscanner begin/build/ test/end on push to main, pull requests and manual dispatch. - sonar.qualitygate.wait=true on pull_request events only: the Sonar way gate evaluates new code, so a red build means the PR introduced issues. The first push to main is the baseline (everything counts as new) and must not block CI on pre-existing debt. - The analysis build passes TreatWarningsAsErrors=false: SonarScanner injects its own Roslyn analyzers for that build only. The zero-warnings gate is unchanged in ci.yml, and the solution still has no SonarAnalyzer package reference by design. - PR parameters are passed explicitly because the scanner does not auto-detect GitHub Actions. - Job is skipped for Dependabot and fork PRs (no repository secrets). - coverlet.runsettings: emit opencover alongside cobertura so SonarCloud imports coverage (check-coverage.mjs still reads cobertura only). - .sonarqube/ added to .gitignore (scanner working directory).
github.event.pullrequest.number does not exist (the pull_request payload key uses an underscore); the empty value made the scanner reject sonar.pullrequest.key and abort the analysis.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
.github/workflows/sonarcloud.yml: SonarScanner for .NET (begin → build → test with coverage → end) onpushto main,pull_requestandworkflow_dispatch.sonar.qualitygate.wait=trueon PR events only — the Sonar way gate evaluates new code (Clean as You Code), so a red check here means this PR introduced issues. The first push to main is the baseline (everything counts as new) and must not block CI on pre-existing debt.-p:TreatWarningsAsErrors=falsebecause SonarScanner injects its own Roslyn analyzers for that build. The gate inci.yml(build-and-test job) is untouched, and the solution still has no SonarAnalyzer package — SonarCloud is the only analyzer, as decided in the plan.coverlet.runsettingsnow emits opencover alongside cobertura so SonarCloud imports coverage;check-coverage.mjs(85% gate) still reads cobertura only and is unchanged.fetch-depth: 0gives SonarCloud the blame data needed for new-code detection..sonarqube/(scanner working dir) added to.gitignore.Setup already done
santidev21imported/bound to GitHub; projectsantidev21_MyBudgetBotcreated.SONAR_TOKENrepository secret configured.Not touched
ci.ymlgates (build with zero warnings,dotnet format, 85% coverage) remain the source of truth.