-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-14720: [Dev] Update merge_arrow_pr script to accept GitHub issues #14750
Conversation
amol-
commented
Nov 28, 2022
•
edited
Loading
edited
- Closes: MIGRATION: [Developer] The merge_arrow_pr script should be able to handle issues on GitHub and JIRA #14720
FYI, I tested the changes to the merge script by merging #14762. Merging itself went fine. When it asked "Would you like to update the associated JIRA? (y/n)", I said no (because there is no JIRA), but maybe I should have said yes to see to how the github issue got updated? (closed, assigned, ..)? In that case, we should probably update the wording of the question. |
Good catch, you were supposed to answer "yes" but as you noticed the wording is wrong. I'll update it to mention GitHub too. |
Ah, I see you also updated it to be able to test on another repo .. In any case, I already just tested on another PR, but updating the issue failed: #14745
Now, the comment seems to actually be posted (#14745 (comment)), so I don't know exactly how to interpret that failure. The comment body should also be updated for GitHub (will comment inline) |
dev/merge_arrow_pr.py
Outdated
cmd.continue_maybe("Would you like to update the associated JIRA?") | ||
jira_comment = ( | ||
cmd.continue_maybe("Would you like to update the associated issue?") | ||
issue_comment = ( | ||
"Issue resolved by pull request %s\n[%s/%s]" |
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.
For posting this on GitHub issues, the formatting doesn't need to include the [
]
(I would personally also remove the newline and double PR number/url for GitHub (since the url gets rendered as a number anyway)
So something like
"Issue resolved by pull request GH-%s" with just the pr_num (or using the full url, and then the message can maybe be the same for both JIRA and GitHub)
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.
Yes, I'm aware of that. I tweaked it a little bit so that it works reasonably on both GitHub and Jira.
See https://github.com/amol-/arrow/issues/3
We can refine it further in the future, at the moment my goal was to make it good enough for both Jira and Github.
PS: I still need to test it against a Jira issue as I did some changes on the Jira side too.
You still have some linting issues (line length) |
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.
+1
dev/merge_arrow_pr.py
Outdated
try: | ||
self.issue = self.github_api.get_issue_data(github_id) | ||
except Exception as e: | ||
self.cmd.fail("Github could not find %s\n%s" % (github_id, e)) |
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.
self.cmd.fail("Github could not find %s\n%s" % (github_id, e)) | |
self.cmd.fail("GitHub could not find %s\n%s" % (github_id, e)) |
dev/merge_arrow_pr.py
Outdated
(self.github_id, fix_version)) | ||
else: | ||
self.github_api.assign_milestone(self.github_id, fix_version) | ||
self.github_api.close_issue(self.github_id, comment) |
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.
We may not need this because we can use GitHub's auto close feature by close GH-XXX
commit message.
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.
I've decided to validate whether the message Closes: #XXX
is in the body as expected from the dev_pr workflow:
https://github.com/apache/arrow/blob/master/.github/workflows/dev_pr/link.js#L85
otherwise we close the issue. That will close issues that might have been created after an initial MINOR PR if we forgot to add the Closes
or if the description was manually modified, etcetera.
dev/merge_arrow_pr.py
Outdated
# We can merge both ARROW and PARQUET patches | ||
GITHUB_PR_TITLE_REGEXEN = re.compile(r'^GH-([0-9]+)\b.*$') | ||
JIRA_SUPPORTED_PROJECTS = ['ARROW', 'PARQUET'] |
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.
# We can merge both ARROW and PARQUET patches | |
GITHUB_PR_TITLE_REGEXEN = re.compile(r'^GH-([0-9]+)\b.*$') | |
JIRA_SUPPORTED_PROJECTS = ['ARROW', 'PARQUET'] | |
GITHUB_PR_TITLE_REGEXEN = re.compile(r'^GH-([0-9]+)\b.*$') | |
# We can merge both ARROW and PARQUET patches | |
JIRA_SUPPORTED_PROJECTS = ['ARROW', 'PARQUET'] |
dev/merge_arrow_pr.py
Outdated
@@ -322,6 +440,13 @@ def continue_maybe(self, prompt): | |||
|
|||
|
|||
class PullRequest(object): | |||
# We can merge both ARROW and PARQUET patches | |||
GITHUB_PR_TITLE_REGEXEN = re.compile(r'^GH-([0-9]+)\b.*$') |
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.
I think that REGEXEN
meant "N regular expressions". (I think that "EXE" is a typo of "EXP" or EX
.)
This is just one regular expression. How about GITHUB_PR_TITLE_REGEX
or GITHUB_PR_TITLE_PATTERN
?
dev/merge_arrow_pr.py
Outdated
options = ' or '.join('{0}-XXX'.format(project) | ||
for project in self.JIRA_SUPPORTED_PROJECTS) |
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.
Can we add GH-XXX
too?
dev/merge_arrow_pr.py
Outdated
return JiraIssue(self.con, jira_id, project, self.cmd) | ||
options = ' or '.join('{0}-XXX'.format(project) | ||
for project in self.JIRA_SUPPORTED_PROJECTS) | ||
self.cmd.fail("PR title should be prefixed by a jira id " |
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.
self.cmd.fail("PR title should be prefixed by a jira id " | |
self.cmd.fail("PR title should be prefixed by a GitHub ID or a Jira ID " |
dev/merge_arrow_pr.py
Outdated
return [x for x in all_versions if x.name == version_str][0].raw | ||
|
||
return [get_version_json(v) for v in issue_fix_versions] | ||
issue_fix_version = cmd.prompt("Enter comma-separated " |
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.
Do we still support comma-separated fix version?
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.
we don't, I have changed the comment to: Enter fix version [%s]:
, I am not sure how useful is that but I think we can add this functionality as an improvement later on if required.
ordered_versions = merge_arrow_pr.JiraIssue.sort_versions(versions) | ||
assert ordered_versions[0].name == "10.0.0" | ||
fix_version = merge_arrow_pr.get_candidate_fix_version(versions) | ||
assert fix_version == "9.0.0" |
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.
Do we want to add tests for GitHubIssue
like existing JiraIssue
tests?
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.
Sounds like a good idea. I've added a ticket to track this separately if that's ok: #14802
dev/merge_arrow_pr.py
Outdated
@@ -32,8 +32,8 @@ | |||
# Configuration environment variables: | |||
# - APACHE_JIRA_TOKEN: your Apache JIRA Personal Access Token | |||
# - ARROW_GITHUB_API_TOKEN: a GitHub API token to use for API requests | |||
# - PR_REMOTE_NAME: the name of the remote to the Apache git repo (set to | |||
# 'apache' by default) | |||
# - ORG_NAME: the name of the remote to the Apache git repo |
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.
How about ARROW_GITHUB_ORG
or ARROW_GITHUB_OWNER
because ARROW_GITHUB_API_TOKEN
has ARROW_GITHUB_
prefix?
the remote to the Apache git repo
Could you also update this description?
Is component name missing in this title? |
NOTE: I didn't try this. I just reviewed source code. Please let me know if I should try this. |
I already tried it with both PRs that close JIRA or GitHub issues, and that seems to be working fine. |
I've tested on my fork and all looks good. PR was merged successfully and issue was closed as expected:
|
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.
Latest changes look good to me!
@kou I am going to merge this, since we have several PRs open that need this to be able to be merged. I think the remaining items can be done as follow-ups, as Raúl indicated |
And I merged this PR with the PR itself, and that seems to have gone fine! (the issue was closed because of the link in the body) |
Benchmark runs are scheduled for baseline = 958fbfa and contender = 1ba97a6. 1ba97a6 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |