Skip to content

Update sonar-check.yml to manage coverage comments - #13878

Open
DaanHoogland wants to merge 2 commits into
mainfrom
DaanHoogland-patch-7
Open

Update sonar-check.yml to manage coverage comments#13878
DaanHoogland wants to merge 2 commits into
mainfrom
DaanHoogland-patch-7

Conversation

@DaanHoogland

Copy link
Copy Markdown
Contributor

Refactor coverage comment handling to update existing comments if present.

Description

This PR...

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Refactor coverage comment handling to update existing comments if present.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Sonar/coverage GitHub Actions workflow so the “coverage grade” bot comment on pull requests is updated in-place when a prior comment exists, instead of always posting a new comment.

Changes:

  • Adds a hidden marker (<!-- coverage-grade-bot -->) to reliably identify the workflow’s coverage-grade comment.
  • Switches from always creating a PR comment to listing comments and updating an existing matching comment when present.
  • Falls back to creating a new comment when no existing marked comment is found.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/sonar-check.yml Outdated
Comment on lines +111 to +116
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));
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.41%. Comparing base (dbee809) to head (43fc583).

❗ There is a different number of reports uploaded between BASE (dbee809) and HEAD (43fc583). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (dbee809) HEAD (43fc583)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               main   #13878       +/-   ##
=============================================
- Coverage     19.64%    3.41%   -16.24%     
=============================================
  Files          6368      487     -5881     
  Lines        574889    41867   -533022     
  Branches      70353     7912    -62441     
=============================================
- Hits         112935     1429   -111506     
+ Misses       449684    40238   -409446     
+ Partials      12270      200    -12070     
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread .github/workflows/sonar-check.yml Outdated
Copilot AI review requested due to automatic review settings August 14, 2026 13:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

.github/workflows/sonar-check.yml:115

  • issues.listComments returns only the first page by default (30 comments). On PRs with many comments, the bot’s previous coverage comment may not be in the first page, causing this job to post a duplicate instead of updating. Paginate (or at least increase per_page) and make the marker check resilient to a missing body.
            const { data: comments } = await github.rest.issues.listComments({
              owner:        context.repo.owner,
              repo:         context.repo.repo,
              issue_number: context.issue.number,
            });

.github/workflows/sonar-check.yml:114

  • This step calls issues.listComments, issues.updateComment, and issues.createComment, which require issues permission on GITHUB_TOKEN. The workflow currently only grants contents: read and pull-requests: write, so these API calls can fail with 403 depending on repository default token permissions. Consider explicitly adding issues: write under the workflow/job permissions: block.
            const { data: comments } = await github.rest.issues.listComments({
              owner:        context.repo.owner,
              repo:         context.repo.repo,
              issue_number: context.issue.number,

@Pearl1594 Pearl1594 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants