Add GitHub Actions Changelog Bot#5811
Conversation
|
It's working except for the following error when trying to push the change to the PR branch. It may not be possible to get this working because if it was surely anyone could open a PR with a new GitHub Action to push whatever they want to |
|
This should probably be added to https://github.com/OpenAstronomy/baldrick instead as an optional plugin. Should be able to implement #4715 in the same plugin also. |
|
There already is a PR! OpenAstronomy/baldrick#95 |
Does this mean we should close this PR? |
|
They both work in totally different ways and the other PR is a work in progress (and 2 years old). It's worth considering/combining both when expanding the packaging infrastructure. |
Signed-off-by: Conor MacBride <conor@macbride.me>
Signed-off-by: Conor MacBride <conor@macbride.me>
Signed-off-by: Conor MacBride <conor@macbride.me>
Signed-off-by: Conor MacBride <conor@macbride.me>
Signed-off-by: Conor MacBride <conor@macbride.me>
and upgrade some of the actions versions
743b370 to
0c4bb9c
Compare
|
Wanna merge this and test it here, or you wanna test it on a different repo? |
|
If you like. Are you generally okay with the implementation? Possible downsides: It commits to the PR branch every time a changelog is added, removed or updated, possibly resulting in multiple commits if there are lots of changes. It will also delete any manually committed changelogs for the PR number (unless the no changelog needed tag is added). And it has the issue with people needing to pull the changes back to their local branch. |
|
We could instead create an "Update Changelog" label which, when added, triggers this workflow. (And the workflow would also remove the label, so it can be added again later.) The current behaviour would be very bad for existing PRs as they would get their changelogs deleted when we add labels such as no backport. |
| # markdown heading of "Changelog [category]" | ||
| # followed by a message in the next ``` code block. | ||
| body = re.sub("(<!--.*?-->)", "", body, flags=re.DOTALL) | ||
| regex = r"[#]+[ ]*Changelog[ ]*\[([a-zA-Z]+)\]*[^`]*```([^`]*)```" |
There was a problem hiding this comment.
If we don't find anything in body of the PR can we terminate the action from here?
There was a problem hiding this comment.
Currently, if you remove the a Changelog from the main PR comment it deletes that Changelog from the PR branch. If we set it to exit here it would make deleting changelogs inconsistent, I.e: if you have two Changelog entries (feature and bugfix) and remove the feature Changelog from the comment it will be deleted in the PR branch, however, if you then remove the bugfix Changelog (so no regex match) it won't be deleted from the PR branch.
There was a problem hiding this comment.
Hmmm, that does make sense, but I don't think we should be deleting files people are adding manually either. If we can't delete entries from the PR description because of that, then I think that's a price we would have to pay. Unless we can come up with some other idea.
| if len(text) > 0: # ignore empty messages | ||
| entries += [(filename, text)] | ||
|
|
||
| for existing in glob.glob(os.path.join(path, f"{pr}.*.rst")): |
There was a problem hiding this comment.
I am trying to think of a way we can detect that the action added the file rather than just nuking all changelogs.
Could we use git to pull the commit message of the last commit editing the file and see if we have a unique string in that message? That means that if the last commit wasn't the changelog bot then we don't delete it and instead we error?
There was a problem hiding this comment.
Could run e.g. git log -s -n1 --pretty='format:%an %ae%n' changelog/6032.feature.rst on each file before deleting, and only delete if it's the SunPyBot?
There was a problem hiding this comment.
Actually, it would be much simpler (and with less surprises) if this workflow can only commit if all the existing changelog entries for the PR were last edited by the bot. (Because otherwise it's complicated to handle multiple changelogs of the same type where some are controlled by the bot and some are manually controlled.)
There was a problem hiding this comment.
That would be fine with me as well.
There was a problem hiding this comment.
Which would you prefer? Bot command or top comment? Top comment would be easiest to implement (as that's what we have already), although happy to switch to bot command if you would prefer.
There was a problem hiding this comment.
I can't find a reliable way to check if the comment author should have permission to push to the PR branch (as the workflow will always have permission). So, if you don't mind, I'll just keep it as updating the top comment so permissions can be enforced. I'll add the check mentioned above.
| if len(entries) == 0: | ||
| raise ValueError("No new changelog entries found.") |
There was a problem hiding this comment.
If we did this above the deletion then we wouldn't remove entries in PRs without the magic comment?
|
The other option is rather than using a magic heading in the top comment we could require you to @ a bot in a comment to make a change to the log entry? i.e. i.e. use https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment |
|
I like the magic heading in the top comment because it makes it easier to update existing entries (rather than copying and pasting) and edit all the changelogs in the one place. Maybe the bot comment is more intuitive though? |
|
I like the idea of the top comment, but it's a stateful interface i.e. handling deletes and edits etc, when the nature of actions is stateless, it's kinda hard to graft the stateful UI onto the stateless actions. Where as responding to specific commands in a comment means that the UI is also stateless. |
|
That makes sense. The comment should work well then. For the API design: If no existing files match If This will update the contents of This will delete the file The workflow will react to the comment with 👍 on success and 👎 on error. |
|
Sounds great! |
|
Need a way to ignore comments from people who do not have write access to the PR branch... |
77998ee to
ba1e766
Compare
|
The git-auto-commit-action documentation says that a How about we merge this so we can test it? |
I am pro this. |
Description
This is a new GitHub Action that commits changelog entries that are in the PR message. This still needs a lot of testing before merging.
Changelog [feature]
Fixes #5415