arduino / report-size-deltas

GitHub Actions action that comments on pull requests with a report of change in memory usage of Arduino sketches
Other
14 stars 8 forks source link

update comment if it exists #90

Open 2bndy5 opened 8 months ago

2bndy5 commented 8 months ago

Describe the request

Instead of posting a new comment every time this action is run, would it be feasible to update an existing comment if it exists? This request is meant to reduce the notifications/emails that get triggered.

Codecov had to support a new config option to allow such behavior. See additional context below about identifying bot comments.

Describe the current behavior

I could set the action to only run when a PR is opened or re-opened. But if I want a new report generated/posted after changes have been made to an already open PR, then I have to close and re-open the PR. This makes refreshing the reports in a PR not intuitive for team members that are not intimately familiar with github actions.

If I set the action to run on a PR sync event, then the old comment remains while a new comment is posted. This makes it feel like a bot is spamming the PR thread. Furthermore, I have to manually hide any previous report comments to reduce the visual noise in the PR thread.

'arduino/report-size-deltas' version

arduino/report-size-deltas@v1

Additional context

I know that comments posted with the generic builtin "github-actions" bot are not exclusive to the action that posted the comment (presumably via REST API). For my cpp-linter-action's thread-comments feature, we decided to include a HTML comment as the first line of the thread comment to identify which one(s) were posted by our cpp-linter-action. This works well for REST API requests that employ the raw media type (which seems to the default when applicable).

Of course, identifying a comment would be easier if using a registered GitHub App, but my understanding is that would require hosting a webapp from a server which can be costly.

Issue checklist

2bndy5 commented 8 months ago

I started a branch to attempt this, but I haven't tested it yet https://github.com/arduino/report-size-deltas/compare/main...2bndy5:report-size-deltas:update-comment

I added a new action input named update-comment. It defaults to false to preserve current behavior (backward compatible).

2bndy5 commented 8 months ago

I ran a preliminary test on a recent PR with 2 identical report comments, and it worked as expected: deleted all but first report comments and updated the first report comment. However, github is not showing any edits to the updated report comment since it's contents were technically not changed.

I plan to do some more involved field testing on a private dummy repo, but I'm not sure how far I should take these field tests... @per1234 Is this feature request desirable?

2bndy5 commented 8 months ago

My changes work on a private repo also. The only hitch with a private repo is that GITHUB_TOKEN(by default) doesn't seem to have sufficient access to the repo to run arduino/compile-sketches action. Using a personal access token (classic) fixed that (and comments posted were made on my behalf, not some generic "github-actions" bot).

2bndy5 commented 8 months ago

... include a HTML comment as the first line of the thread comment to identify which one(s) were posted by our cpp-linter-action. While this works well for public repos, it has not worked for private repos; comments returned by REST API for private repos had some content (HTML syntax in our case) stripped away.

This problem does not apply to this repo because the media type used here: https://github.com/arduino/report-size-deltas/blob/438db04f1df79d80e5633f258310a00e4febd4f4/reportsizedeltas/reportsizedeltas.py#L629 defaults to raw+json for the REST API endpoint /repos/{owner}/{repo}/issues/{PR_number}/comments (per github docs).

2bndy5 commented 5 months ago

ping @per1234