You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2026/08/14 13:20:03 UTC
(cloudstack) 01/01: Update sonar-check.yml to manage coverage comments
This is an automated email from the ASF dual-hosted git repository.
DaanHoogland pushed a commit to branch DaanHoogland-patch-7
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 500a3b5639c934c521e355f94e309ca3a8bc0468
Author: dahn <da...@onecht.net>
AuthorDate: Fri Aug 14 15:19:53 2026 +0200
Update sonar-check.yml to manage coverage comments
Refactor coverage comment handling to update existing comments if present.
---
.github/workflows/sonar-check.yml | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/sonar-check.yml b/.github/workflows/sonar-check.yml
index fbb3cb9f540..250b601cacb 100644
--- a/.github/workflows/sonar-check.yml
+++ b/.github/workflows/sonar-check.yml
@@ -80,12 +80,14 @@ jobs:
const emojiMap = { A: '🟢', B: '🟡', C: '🟠', D: '🔴', F: '⛔' };
const emoji = emojiMap[grade] ?? '❓';
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
+ const marker = '<!-- coverage-grade-bot -->';
const branchRow = branchPct !== 'N/A'
? `| Branch coverage | **${branchPct}%** |`
: '';
const body = [
+ marker,
`## ${emoji} Test Coverage Grade: \`${grade}\` — ${label}`,
'',
'| Metric | Value |',
@@ -106,10 +108,26 @@ jobs:
`> [View full Actions run](${runUrl})`,
].filter(l => l !== undefined).join('\n');
- await github.rest.issues.createComment({
+ const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
- body: body,
});
- console.log('Posted coverage grade comment');
+ const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(marker));
+ if (existing) {
+ await github.rest.issues.updateComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ comment_id: existing.id,
+ body: body,
+ });
+ console.log('Updated existing coverage grade comment');
+ } else {
+ await github.rest.issues.createComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: context.issue.number,
+ body: body,
+ });
+ console.log('Posted coverage grade comment');
+ }