Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .github/workflows/sonar-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@
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 |',
Expand All @@ -106,10 +108,26 @@
`> [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.login === 'github-actions[bot]' && c.body.includes(marker));

Check failure on line 116 in .github/workflows/sonar-check.yml

View workflow job for this annotation

GitHub Actions / Run pre-commit

116:12 syntax error: expected <block end>, but found '<scalar>' (syntax)
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');
}
Loading