chore(ci): enable SonarCloud scan on pull-request builds#561
Open
alexandru-petre wants to merge 1 commit into
Open
chore(ci): enable SonarCloud scan on pull-request builds#561alexandru-petre wants to merge 1 commit into
alexandru-petre wants to merge 1 commit into
Conversation
PR #559 restored Sonar for non-PR builds and left a temporary `ne(Build.Reason, 'PullRequest')` guard pending SonarCloud admin work (stale `master` main branch, missing long-lived branch pattern, conflicting Automatic Analysis). That admin work is now done, so the guard is removed from all three sites: - PublishSonar stage condition in stage.start.yml - prepare-sonar-coverage condition in stage.build.yml - upload-sonar-build-output condition in stage.build.yml The IsFork and masters/* / support/* exclusions stay — they protect fork PRs (no secrets) and direct pushes to protected branches. SONARCLOUD_ADMIN_CHECKLIST.md is removed (its four steps are complete). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Context
This repo's Azure Pipelines run a SonarCloud scan as part of the per-pack build (Cryptography, Database, FTP, Java, Python, Credentials). PR #559 vendored the Sonar templates locally and restored Sonar after a long outage, but PR-time scanning was held back behind an explicit
ne(Build.Reason, 'PullRequest')guard while a separate SonarCloud-admin punch list was worked through.Problem Statement
PR builds currently skip Sonar entirely — no scan, no PR decoration, no coverage delta comment on GitHub. Reviewers and contributors get no early signal on code-quality or coverage regressions until after merge to
develop, which is too late to course-correct.Behavior Before This PR
A contributor opens a PR against
develop. The pack pipeline runs Build → Test successfully, and then:PublishSonarstage is skipped (PR builds excluded by Build.Reason guard).SonarCloudPrepareand the post-build Sonar upload steps inside the Build stage are also skipped by the same guard.Behavior After This PR
Same scenario — a contributor opens a PR against
developfrom a same-repo branch. The pack pipeline runs Build → Test, and then:SonarCloudPrepareruns in the Build stage.PublishSonarstage runs: merge-commit reconstruction (already in place since chore(ci): vendor AzurePipelinesTemplates, restore Sonar, harden CI #559)Fork PRs and direct pushes to
masters/*/support/*remain excluded — theIsForkguard and thestartsWithbranch exclusions are preserved on all three conditions.Implementation
The change removes one clause (
ne(variables['Build.Reason'], 'PullRequest')) from threecondition:expressions and tightens the prose comment block that previously documented the temporary exclusion. The deletedSONARCLOUD_ADMIN_CHECKLIST.mdwas a hand-off document for the SonarCloud admin work that gated this restoration — all four of its steps (main branch rename, long-lived branch pattern, Automatic Analysis off, baseline) are now done.Caveats / Potential Issues
developre-baselines, the first PR scans against a fresh baseline and may flag accumulated drift as "new code", failing the gate purely on coverage delta. If this happens, the SonarCloud admin should set Administration → New Code → Specific date to just before the first restored analysis ondevelop. This is a SonarCloud-side knob, not a pipeline change.SONARQUBE_ENDPOINTsecret; only fork PRs strip secrets, and those remain excluded by theIsForkguard.How to Test
PublishSonaras skipped on this PR.SonarCloudPrepare,SonarCloudAnalyze, andSonarCloudPublisheach show a green check in the build log.masters/*orsupport/*branch and confirm Sonar still skips those direct pushes (thestartsWithguards still apply).