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

github-actions: Auto-backporting #4775

Merged
merged 1 commit into from
Aug 29, 2022

Conversation

bookinabox
Copy link

A work-in-progress implementation of semi-automating the backporting
process.

This implementation has two steps:

  1. Checking whether any associated issues are marked as bugs

    If they do, mark with auto-backport label

  2. On a successful merge, if there is a auto-backport label and there
    are any tags of backport-to-BRANCHNAME, it calls an action that
    cherry-picks the commits in the PR and automatically creates a PR to
    those branches.

This action uses https://github.com/sqren/backport-github-action

Currently, I copied and modified the hub-util.sh script from
kata-containers/.github.scripts/hub-util.sh to include a function to
output the labels JSON associated with an issue to find the labels.

If this approach looks good, I will remove that script from here and
make a separate PR to that repo to add this utility.

Fixes #3618

Signed-off-by: Derek Lee derlee@redhat.com

@katacontainersbot katacontainersbot added the size/huge Largest and most complex task (probably needs breaking into small pieces) label Jul 29, 2022
@bookinabox bookinabox force-pushed the auto-backport branch 3 times, most recently from ab78f47 to c06be73 Compare August 1, 2022 20:59
@bookinabox
Copy link
Author

I made the changes to the .github repo as well. I will remove them from this PR if those look good. kata-containers/.github#46

@bookinabox bookinabox marked this pull request as ready for review August 8, 2022 15:52
@@ -0,0 +1,1045 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this script being copied into this repo (from https://github.com/kata-containers/.github/blob/main/scripts/hub-util.sh)?

If we only want it here (and I'm not sure we do as we have other repos), that needs to be documented in the commit, and an issue raised in the .github repo to delete the original version of this script.

Copy link
Author

Choose a reason for hiding this comment

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

I copied it to this repo to make it possible to test it before it was merged into that repo, since the action pulls it from github. I planned on deleting it once that script was merged in.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @jodh-intel @bookinabox , I just merged kata-containers/.github#46 so that we will be able to remove the script from this PR.

@bookinabox
Copy link
Author

bookinabox commented Aug 15, 2022

Not sure why it can't find the API url. I suspect it might be because its across repos? I don't see why that would work but the move-in-progress would fail and I did get this to work on my fork. Will mess around more with this.

Edit: It's very puzzling to me because move-issue-to-in-progress went off fine. Besides being across repos, there's also that when I was testing on my fork I used GITHUB_TOKEN instead of KATA_GITHUB_ACTIONS_TOKEN since my fork does not have the copied secrets.

Edit2: Weird, I remember seeing the add backport label on this check before, but I no longer see it. Perhaps I was looking at the wrong thing before? I know on my local fork the action did not appear until I merged into main.

@katacontainersbot katacontainersbot added size/large Task of significant size and removed size/huge Largest and most complex task (probably needs breaking into small pieces) labels Aug 17, 2022
@bookinabox
Copy link
Author

I removed the duplicate hub-util script from here and tested on my fork.

@wainersm
Copy link
Contributor

A work-in-progress implementation of semi-automating the backporting process.

Great, it seems promising!

This implementation has two steps:

1. Checking whether any associated issues are marked as bugs
   If they do, mark with `auto-backport` label

Currently there the action "Add backport label / check-issues " that checks if the PR has either 'needs-backport' or 'no-backport-needed'. This PR itself didn't pass that check. :)

So we will need to consider the scenarios too:

  1. if the PR was opened with 'no-backport-needed' then auto-backport does nothing
  2. if the PR was opened with 'needs-backport' than add the 'auto-backport' label (and don't need to check the issue type)
  3. the PR was opened without any backport label, afterwards the contributor add the label.
2. On a successful merge, if there is a `auto-backport` label  and there
   are any tags of `backport-to-BRANCHNAME`, it calls an action that
   cherry-picks the commits in the PR and automatically creates a PR to
   those branches.

Is it possible for the action to add a comment on the pull request saying that now the contributor needs to tag the PR properly?

Apart from that:

  1. As part of the release process, it will be needed to create the backport-to-BRANCHNAME by an admin of the repository. Thus, we will need to update that doc: https://github.com/kata-containers/kata-containers/blob/main/docs/Release-Process.md
  2. We will likely to document the auto-backport action in https://github.com/kata-containers/kata-containers/blob/main/docs/Stable-Branch-Strategy.md

This action uses https://github.com/sqren/backport-github-action

Currently, I copied and modified the hub-util.sh script from kata-containers/.github.scripts/hub-util.sh to include a function to output the labels JSON associated with an issue to find the labels.

If this approach looks good, I will remove that script from here and make a separate PR to that repo to add this utility.

Fixes #3618

Signed-off-by: Derek Lee derlee@redhat.com

@wainersm
Copy link
Contributor

Hi @fidencio @snir911 @amshinde @bergwolf @egernst , as you are in the release rota team, we would appreciate your feedback here. All in all, the idea behind this PR is to ease backport of fixes so that you don't need to cherry-pick yourself fixes at the release time or chase people to do so. Ah, bear in mind that @bookinabox is going to finish his internship in two weeks then there isn't time to implement a more sophisticated workflow.

@bookinabox
Copy link
Author

bookinabox commented Aug 19, 2022

@wainersm I added the PR label check (needs-backport vs no-backport-needed), but this again required changes to hub-utils

I also added the automatic comment.

As far as I can tell, there is no easy way I can have it detect when someone adds a label to the PR though :(. If anyone knows of any way to do that it would be appreciated. nvm we can do it with pull_requests, labeled, unlabeled

An implementation of semi-automating the backporting
process.

This implementation has two steps:
1. Checking whether any associated issues are marked as bugs

   If they do, mark with `auto-backport` label

2. On a successful merge, if there is a `auto-backport` label  and there
   are any tags of `backport-to-BRANCHNAME`, it calls an action that
   cherry-picks the commits in the PR and automatically creates a PR to
   those branches.

This action uses https://github.com/sqren/backport-github-action

Fixes kata-containers#3618

Signed-off-by: Derek Lee <derlee@redhat.com>
@bookinabox
Copy link
Author

^ I improved/fixed how the automatic labeling works.

  • Now it will ignore changes to auto-backport (adding/removing it), and will run for any other label change. Adding needs-backport will trigger adding auto-backport.
  • Adding no-backport-needed will remove auto-backport if it exists.
  • Having both with confuse it, but it will default to removing auto-backport.
  • If there previously was no auto-backport label and we are adding one, it should also comment reminding people to add add backport-to-____.
  • I no longer require the hub-utils change (missed an easier way to do it earlier)

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

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

Thanks @bookinabox!

lgtm

Copy link
Contributor

@wainersm wainersm left a comment

Choose a reason for hiding this comment

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

Thanks @bookinabox ! LGTM.

@wainersm
Copy link
Contributor

/test

@bookinabox
Copy link
Author

@bookinabox
Copy link
Author

bookinabox commented Aug 25, 2022

Not sure why jenkins-metrics-ubuntu-20-04 is failing

@katacontainersbot
Copy link
Contributor

Can one of the admins verify this patch?

@wainersm
Copy link
Contributor

Not quite sure why jenkins-metrics-ubuntu-20-04 is failing

Sometimes it simply fail. The fail is not related with this PR, let me re-run the job.

/test-metrics

@wainersm
Copy link
Contributor

/test-metrics

@wainersm
Copy link
Contributor

/test-ubuntu-metrics

@wainersm
Copy link
Contributor

Hi @GabyCT ! Is there any known issue with the metrics job? It failed twice for this PR which has changed unrelated.

@wainersm
Copy link
Contributor

Hi @GabyCT ! Is there any known issue with the metrics job? It failed twice for this PR which has changed unrelated.

never mind :)

@wainersm wainersm merged commit cd5be6d into kata-containers:main Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/large Task of significant size
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatic backporting of pull requests
4 participants