-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[ZEPPELIN-6089][INFRA] Improve the merge PR script #4831
Conversation
# will be unauthenticated. You should only need to configure this if you find yourself regularly | ||
# exceeding your IP's unauthenticated request rate limit. You can create an OAuth key at | ||
# https://github.com/settings/tokens. This script only requires the "public_repo" scope. | ||
GITHUB_OAUTH_KEY = os.environ.get("GITHUB_OAUTH_KEY") |
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.
both JIRA and GITHUB encourage using TOKEN instead of PASSWORD for security purposes.
|
||
|
||
def grant_contributor_role(user: str): | ||
role = asf_jira.project_role("ZEPPELIN", 10010) |
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.
not sure if this is correct, I don't have the Zeppelin project JIRA admin permission
IIRC, this script closes PRs instead of merging them. Can we use github API to merge the PR? It's the reason why I prefer to use github's merge button.
If the script works properly, I don't care to revert it :-) |
It is more important to me that we have a reasonable GitHub history than the history on the mirrored Apache Git instance. In my opinion, most developers are working on the Zeppelin code via GitHub. Where did you get the screenshots? If we get both, that's fine with me, but I don't think the Squash&Merge feature should be disabled for that. Working with a merge script is fine with me. As you wrote, this can simplify many things. |
Yes, this is a drawback. If you look at Spark's PRs, the committer who merged the PR will clarify that by commenting something like "Merged to master/3.5".
A git GUI client, https://fork.dev/
Okay, and I'm not against using this approach, as long as the committer does not forget to do other things manually. |
I have a new idea. How about using github action more? E.g. we can trigger it by approving it, then change the commit message with squash and amend the commit. WDYT? |
@jongyoul GitHub Actions can not solve backport and update JIRA information issues. |
Additionally, I think it's hard to write a rule to evaluate whether the PR is ready for merge. Even if the PR receives sufficient approval, it still has a chance of having unaddressed comments or concerns from other reviewers. Committing code to the codebase is serious, and I think we should judge the check-in condition manually(either by clicking a button, or by using a script). |
I mean using the logic implemented in our current script. For cherry-pick, we can make a ticket like
It will work /cherry-pick branch-0.11 For JIRA Update,
It will update JIRA ticket as well. FYI, this code is generated by GPT and we should modify something. I would just like to give you an idea. I use a similar way to manage other codes. |
I also don't want to merge some commits automatically. After reviewing by reviewers, only the commits will be squashed and pushed forcibly into the same PR branch. (We should check if it could work with contributors' branches) |
@jongyoul the script is interactive, it asks the committer to fill in the backport branch and do a local cherry-pick before pushing to repo, if there are some conflicts, it allows the committer to resove it manually and continue the process, in some cases, the cherry-picked code has no line-level conflicts but breaks the compile, committers still have a chance to do a local compile before pushing the code. For updating JIRA, if we use the GitHub Actions, how to tell that the fixed version? by a comment in special words? it's another burden. |
Yes, right. we need to make another function to handle this way. By the way, I agree with Reamer. we need to keep proper histories for Github because most interactions with contributors happen in Github. Merging issues are not dependent on contributors but contributions are related to contributors directly, so I feel like we need to prioritize contributors' experiences. Keeping the experience, using Github buttons or scripting is not essential. |
If you are speaking the PR status, yes, the status merged by the script is "Closed" instead of "Merged", this can not be fixed due to the GitHub API limitation. I don't see contributors confused with that in the other projects that use a similar script for merging PR if we leave proper words at the PR end like "Merged to master/3.5". PS: when I explore a PR with closed status, I usually scroll down to the end to find the close reason. |
We can fix it by squashing it locally in the script, pushing it to the PR, and calling Github API to merge the PR instead of committing and pushing the PR directly to the master.
When I was a contributor, I was confused really because I didn't know why my PR was closed instead of merging even though it exists in the master branch. That's why I insisted on using the Giuthub merge button and tried to work others manually like closing JIRA with the proper fix version and cherry-picking some commits by myself. |
I found an API for merging PR with proper titles and messages. Can we investigate it? We can choose merge_method to squash and merge and add a title and messages when calling it. Using it, we won't break Github's history and can achieve the goal that the script gives to us. |
this involves another drawback https://github.com/orgs/community/discussions/32934 |
But it preserves the author. Could we allow it? |
concerns are
I tend to agree with that. |
Agreed. That's the reason we do the approve button. We can guarantee it by checking the PR's approval. If some PRs weren't approved and we found it, we can revert it. |
Though this violates the git design, given the committer's name is recorded in the commit message body, I'm OK with this approach, let me try this way.
|
@jongyoul I have updated the script to use the GitHub open API you suggested to merge the PR, and have merged 4 PRs 876d1dc 81783dd ad79848 35e1299 to test the cases:
|
@Reamer your concerns are also addressed, now, the merged PR status is "Merged" |
94bfd82
to
a955afc
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
Thanks, merged to master for 0.12 |
What is this PR for?
Zeppelin has
dev/merge_zeppelin_pr.py
that was borrowed from Spark, I would recommend committers use this script over the GitHub button to merge PR, which has some benefits:the tools will ask you to backport the commit to lower maintained branches after you merge a PR to master, if there are no conflicts, all things you need to do are just type a "branch name" that you want to backport.
the script uses the python jira client to update JIRA ticket, for example, automatically closes the JIRA ticket after PR is merged, fills in the fixed versions, which is important to users to know the features/bug fixes applied to versions.
Before
After
This PR syncs the change from the Spark upstream (around 4.0.0-preview2), and has several improvements recently, e.g. support using tokens instead of passwords for GitHub and JIRA authentication. Additionally, this PR switches to the GitHub open API @jongyoul suggested to merge the PR, which fixed the merged PR status from "Closed" to "Merged"
What type of PR is it?
Improvement
Todos
What is the Jira issue?
ZEPPELIN-6089
How should this be tested?
Manually test. Currently not work due to permission issues.
Screenshots (if appropriate)
Questions: