tooling: action to automatically backport changes to earlier branches #18
Labels
No Label
404
backport/v1.19
backport/v1.20
backport/v1.21
meta
new docs
v1.19
v1.20
v1.21
User Research - bug
User Research - communication
User Research - documentation
User Research - feature
User Research - federation
User Research - governance
User Research - release
User Research - security
User Research - testing
User Research - UI
User Research - UX
No Milestone
No Assignees
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: forgejo/docs#18
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
It would be great if PRs with a specific tag such as
backport/v1.20
could be automatically cherry-picked onto that branch when the PR is merged.Perhaps a Forgejo Action could achieve that?
We would need a bot user who has access to this repo if we want previews to work. If we don't care about that, the bot can use it's own fork to submit the pull requests.
UPDATE: It would definitely require a bot with write access to this repo if you just want to cherry-pick those commits to the target branch without a pull request, but I feel it would be safer to require at least one human approval in case the automated cherry-pick doesn't work as expected.
I think that would be safe, because the action would only be triggered when a PR is merged, which by definition means it's been reviewed by at least one person who has commit access to the repo. That said, previews probably aren't very important for backports.
I'd actually been imagining it would commit directly to the version branches, but you're right, opening a PR would be better.
With v1.21 it will be possible to run workflows on a regular basis (cron style). Creating or re-using an existing action that does that (cherry-pick from one branch to another + create a PR) is not too complicated and there are plenty of examples to draw inspiration from out there.
Or it could be a workflow that is triggered on push and attempts the backport if the matching PR / issue has the backport label.
I suppose we could also just have a script and a cron job and port it over to Actions when Forgejo v1.21 is available on Codeberg.
@pierreprinetti are you the author of https://github.com/pierreprinetti/backport?
Using mergify is another possibility. It is mature and robust has a lot more features but can also do backporting.I think it would be worth the time.
https://docs.mergify.com/actions/backport/
Backporting bots that are project specific, for inspiration:
Given that there are not too many backports at the moment and there is no immediate need to automate that, I think the wiser choice would be to try and use mergify. The problem with all the other solutions is that they are ad-hoc or not very popular. There are a lot of tiny annoying details to deal with when it comes to backports and it requires regular maintenance.
That being said... my positive impression on mergify has to be mitigated with the fact that:
I am not! It’s Andrea Lamparelli and this is the original repository: https://github.com/kiegroup/git-backporting
We happily use it in Gophercloud (hosted on Github).
Great. Do you think it would be a good fit for Forgejo backports?
It worked for our use-case. I don’t know the requirements of this one well enough to say.
That's what I'd envisaged. I think that would be better than a cron job.
I'd been looking at https://github.com/tibdex/backport, and it looks fine for our use case, but https://github.com/kiegroup/git-backporting also looks interesting.
So far as I can tell it's a proprietary hosted service, which doesn't seem like the sort of thing we tend to use. Or am I missing something? When I click the "Get Started" link for open-source projects on their pricing page, it requires me to sign in with GitHub.
For how long have you been happy with it?
I forgot to reply to this. But my hope is that by making backports very easy, there will be many more of them and at least the last major version of the docs will be kept up to date with the
next
branch as much as possible.But in the meantime, of course, we can do them manually, so indeed it is more important to do it well rather than to do it quickly.
After looking at all the options mentioned so far, https://github.com/tibdex/backport seems to me to be the cleanest and easiest to use. I'll have a go at setting it up tomorrow if nobody else does it first.
Just months, but we’ve had a couple edge cases already.
Our requirements were:
Once you start testing, you’ll likely realise that some of them make assumptions that don’t match your use-case (e.g. the merge strategy). My suggestion is to try them and thoroughly analyse the resulting backports (to a throwaway branch) to see if that’s what you want.
Checks you may want to run:
@pierreprinetti very interesting feedback. One last question: have you considered using https://docs.mergify.com/actions/backport/ when you were researching a solution?
We have not; it didn’t come into our radar range at the time. I wouldn’t be able to compare them unfortunately.
Our config, for reference: https://github.com/gophercloud/gophercloud/blob/master/.github/workflows/backport_v1.yaml
Thanks for the tips @pierreprinetti, there's some very useful things to think about there, though in the case of this docs repo our merge strategy is the opposite of yours (preferring cherry-picking over merging).
@earl-warren I'm still confused by the focus on a proprietary hosted platform which, so far as I can tell, is only compatible with GitHub. What am I missing?
It may be compatible with Forgejo if it is not too tightly GitHub dependent because Forgejo is a little compatible. But the devil is in the details and going with mergify would be a lot of work.
You will want to adapt the example
backport.yml
in your experiments to use a more recent image because it will otherwise fail because the git version is outdated. You need:The complete modified example is:
So far as I can tell it's literally impossible to use outside GitHub because it's a GitHub Application that requires signing in with GitHub to use it. Since it's a hosted SaaS product and not an open source self-hostable tool, I don't see any way we could run it ourselves. Again, unless I'm missing something, I don't see any possibility of using it at all.
Going for the simpler action seems a good choice for now. https://github.com/tibdex/backport should work out of the box. If you would like me to set it up, I'll do it today. Just say the word.
Sure, that would be great. Thanks!
I'm interested to know why there is a need for an additional token? GITHUB_TOKEN is not enough?
@caesar @crystal except for a glitch for which a workaround was implemented, it seems to work fine. See this backported PR for an example.
Looks good @earl-warren!
Perhaps we could set the
head_template
parameter tobackport/<%= base %>/<%= number %>
? This would be more like the structure we already use for PRs (pr/foo
). I prefer it with the slashes because many Git GUIs represent branches with slashes in a directory structure, which significantly reduces visual clutter.Similarly, I would set
label_pattern
to^backport/(?<base>([^ ]+))$
and add the slash back to the label, though that's less important as Forgejo doesn't display labels in a directory structure, and only displays them in groups if they are exclusive. But it would still match better with the label format we use elsewhere.I'll send a PR with both those changes if you agree.
Sounds good, let's do that.
Update: by that I meant that I agree you do that.
The PR must be done by a non-bot account if you want it to trigger actions. Github (and maybe Forgejo?) forbids bot actions to trigger further actions, in order to avoid infinite loops. And we want the backport PRs to trigger CI
There are improvements to make but the logic works well enough to close this issue. If someone feels differently, please re-open.
The backport cherry-picks are committed with Git user
github-actions[bot]
with emailgithub-actions[bot]@users.noreply.github.com
.Unfortunately this value is hardcoded in the
backport
action.It's not a huge deal, just a bit annoying and seemed worth noting here.
Opened an issue upstream: https://github.com/tibdex/backport/issues/106