-
Notifications
You must be signed in to change notification settings - Fork 1.6k
✨ alpha(update): add --open-gh-issue
flag
#5009
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
✨ alpha(update): add --open-gh-issue
flag
#5009
Conversation
Hi @vitorfloriano. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test |
8c465c1
to
cd1c376
Compare
--open-gh-issue
flag
cd1c376
to
1d52e1c
Compare
1d52e1c
to
0d280e3
Compare
|
||
// GitHub integration | ||
if opts.OpenIssue { | ||
// Configure git identity for GitHub integration commits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we just push the branch if we’re in createIssue.
We need to add a check here:
- Check: Do we already have a branch in the repo with outBranchName pushed?
- If yes: Stop the process and show a warning.
The process should end before creating the issue or updating the branch, since we found an existing branch. This is to preserve the existing code and avoid overwriting work. We also won’t open another issue, as it’s likely the task has already been completed.
⚠️ Branch {outBranchName} already exists in the repository.
Skipping issue creation and branch update to preserve existing work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createIssue
calls pushBranchToRemote
, which then calls checkRemoteBranchExists
to check that.
If the branch already exists, it logs:
"Remote branch already exists, skipping push to avoid overwriting existing work"
Then we skip issue creation and log:
"Branch was not pushed (already exists), skipping issue creation"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@camilamacedo86 I did another test just for sanity: https://github.com/vitorfloriano/test-operator/actions/runs/16966361349/job/48091252772#step:5:161
INFO Remote branch already exists, skipping push to avoid overwriting existing work branch=kubebuilder-alpha-update-from-v4.6.0-to-v4.7.1
INFO Branch was not pushed (already exists), skipping issue creation branch=kubebuilder-alpha-update-from-v4.6.0-to-v4.7.1
The branch was not pushed and did not overwrite the existent one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But looking at the code again, we could reorder the checks so this message would be shown regardless of whether the issue already existed or the branch already existed. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INFO Branch was not pushed (already exists), skipping issue creation branch=kubebuilder-alpha-update-from-v4.6.0-to-v4.7.1
The second one can be only from skipping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@camilamacedo86 , I improved the logic and logging to behave as follows:
Case 1: Both branch & issue exist (most common re-run)
Scenario: User runs the command again after everything was already created
INFO Remote branch already exists. Branch was not pushed to avoid overwriting existing work INFO Issue for update already exists. Nothing to do here. from=v4.5.0 to=v4.6.0
Case 2: Branch exists, no issue (issue was deleted/never created)
Scenario: Branch was created before but issue creation failed or was manually deleted
INFO Remote branch already exists. Branch was not pushed to avoid overwriting existing work INFO Creating issue for existing branch branch=kubebuilder-alpha-update-from-v4.5.0-to-v4.6.0
(issue creation proceeds normally)
Case 3: Branch doesn't exist, issue exists (branch was deleted/failed to push)
Scenario: Issue exists but branch was manually deleted or push failed previously
(pushBranchToRemote logs from successful push operation)
INFO Branch was created but issue already exists for this update branch=kubebuilder-alpha-update-from-v4.5.0-to-v4.6.0
WDYT?
- Add --open-gh-issue flag for automated Issue creation on GitHub - Include conflict warning in Issue body - Add comprehensive test coverage and documentation
0d280e3
to
7a31b3c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approved
Let's move forward, to facilitate the progress and we can refine in follow-up if we need. !
Great work 🎉
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, vitorfloriano The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
New changes are detected. LGTM label has been removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/hold
I think in a way to simplify it.
I will try to do it today
Closed in favor of #5018. |
Summary
This PR introduces the
--open-gh-issue
flag, which enhances thekubebuilder alpha update
command with automated GitHub integration and intelligent conflict warning system, making it ready for automated update workflows using GitHub Actions while informing users when manual intervention is needed.Use Case
When used with GitHub Actions,
--open-gh-issue
will:Issue Template
Idempotency
--open-gh-issue
validates if a branch for the same update already exists before pushing anything, which avoids overwritting existing work that may have been started on the update branch.