Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update comment if it exists #90

Open
3 tasks done
2bndy5 opened this issue Feb 20, 2024 · 5 comments · May be fixed by #91
Open
3 tasks done

update comment if it exists #90

2bndy5 opened this issue Feb 20, 2024 · 5 comments · May be fixed by #91
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@2bndy5
Copy link

2bndy5 commented Feb 20, 2024

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

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the latest version
  • My request contains all necessary details
@2bndy5 2bndy5 added the type: enhancement Proposed improvement label Feb 20, 2024
@2bndy5
Copy link
Author

2bndy5 commented Feb 21, 2024

I started a branch to attempt this, but I haven't tested it yet
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).

@per1234 per1234 added the topic: code Related to content of the project itself label Feb 21, 2024
@2bndy5
Copy link
Author

2bndy5 commented Feb 22, 2024

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
Copy link
Author

2bndy5 commented Feb 24, 2024

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
Copy link
Author

2bndy5 commented Feb 24, 2024

... 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:

request.add_unredirected_header(key="Accept", val="application/vnd.github+json")

defaults to raw+json for the REST API endpoint /repos/{owner}/{repo}/issues/{PR_number}/comments (per github docs).

@2bndy5 2bndy5 linked a pull request Feb 24, 2024 that will close this issue
@2bndy5
Copy link
Author

2bndy5 commented May 21, 2024

ping @per1234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants