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

GH-14720: [Dev] Update merge_arrow_pr script to accept GitHub issues #14750

Merged
merged 15 commits into from
Dec 1, 2022
Merged

Conversation

amol-
Copy link
Member

@amol- amol- commented Nov 28, 2022

@amol- amol- changed the title GH-14720: Update merge_arrow_pr script to accept GitHub issues GH-14720 Update merge_arrow_pr script to accept GitHub issues Nov 28, 2022
@amol- amol- changed the title GH-14720 Update merge_arrow_pr script to accept GitHub issues GH-14720: Update merge_arrow_pr script to accept GitHub issues Nov 28, 2022
@jorisvandenbossche
Copy link
Member

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.

@amol-
Copy link
Member Author

amol- commented Nov 29, 2022

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.

@jorisvandenbossche
Copy link
Member

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

Traceback (most recent call last):
  File "/home/joris/scipy/repos/arrow/dev/merge_arrow_pr.py", line 698, in <module>
    cli()
  File "/home/joris/scipy/repos/arrow/dev/merge_arrow_pr.py", line 693, in cli
    pr.issue.resolve(fix_version, issue_comment)
  File "/home/joris/scipy/repos/arrow/dev/merge_arrow_pr.py", line 239, in resolve
    self.github_api.close_issue(self.github_id, comment)
  File "/home/joris/scipy/repos/arrow/dev/merge_arrow_pr.py", line 362, in close_issue
    raise ValueError(f"Failed request: {comment_url} -> {r.json()}")
ValueError: Failed request: https://api.github.com/repos/apache/arrow/issues/14745/comments -> {'url': 'https://api.github.com/repos/apache/arrow/issues/comments/1330536087', ...

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)

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]"
Copy link
Member

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)

Copy link
Member Author

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.

@amol- amol- marked this pull request as ready for review November 29, 2022 12:56
@jorisvandenbossche
Copy link
Member

You still have some linting issues (line length)

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

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))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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))

(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)
Copy link
Member

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.

Copy link
Member

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.

Comment on lines 443 to 445
# We can merge both ARROW and PARQUET patches
GITHUB_PR_TITLE_REGEXEN = re.compile(r'^GH-([0-9]+)\b.*$')
JIRA_SUPPORTED_PROJECTS = ['ARROW', 'PARQUET']
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# 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']

@@ -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.*$')
Copy link
Member

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?

Comment on lines 509 to 510
options = ' or '.join('{0}-XXX'.format(project)
for project in self.JIRA_SUPPORTED_PROJECTS)
Copy link
Member

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?

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 "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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 "

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 "
Copy link
Member

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?

Copy link
Member

@raulcd raulcd Dec 1, 2022

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"
Copy link
Member

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?

Copy link
Member

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

@@ -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
Copy link
Member

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?

@kou
Copy link
Member

kou commented Nov 30, 2022

Is component name missing in this title?
Should we use GH-14720: [Dev] Update ...?

@kou
Copy link
Member

kou commented Nov 30, 2022

NOTE: I didn't try this. I just reviewed source code. Please let me know if I should try this.

@jorisvandenbossche
Copy link
Member

I already tried it with both PRs that close JIRA or GitHub issues, and that seems to be working fine.

@jorisvandenbossche jorisvandenbossche changed the title GH-14720: Update merge_arrow_pr script to accept GitHub issues GH-14720: [Dev] Update merge_arrow_pr script to accept GitHub issues Dec 1, 2022
@raulcd
Copy link
Member

raulcd commented Dec 1, 2022

I've tested on my fork and all looks good. PR was merged successfully and issue was closed as expected:

ARROW_HOME = /home/raulcd/code/arrow/dev
ORG_NAME = raulcd
PROJECT_NAME = arrow
Which pull request would you like to merge? (e.g. 34): 67

=== Pull Request #67 ===
title	GH-48: [Dev] Initial exploration on Python-dev build
source	raulcd/explore-python-dev-build
target	master
url	https://api.github.com/repos/raulcd/arrow/pulls/67
=== GITHUB 48 ===
Summary		[Dev] Testing automatically assign issue
Assignee	raulcd
Components	Python
Status		open
URL		https://github.com/raulcd/arrow/issues/48

Proceed with merging pull request #67? (y/n): y
Author 1: Raúl Cumplido <raulcumplido@gmail.com>
Pull request #67 merged!
Merge hash: 1820dddfe30bc26e0a58a2c227d46c4d03913533

Would you like to update the associated issue? (y/n): y
Enter fix version [11.0.0]: 
Successfully resolved 48!
=== GITHUB 48 ===
Summary		[Dev] Testing automatically assign issue
Assignee	raulcd
Components	Python
Status		closed
URL		https://github.com/raulcd/arrow/issues/48```

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a 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!

@jorisvandenbossche
Copy link
Member

@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

@jorisvandenbossche jorisvandenbossche merged commit 1ba97a6 into apache:master Dec 1, 2022
@jorisvandenbossche
Copy link
Member

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)

@amol- amol- deleted the GH-14720 branch December 1, 2022 13:06
@ursabot
Copy link

ursabot commented Dec 1, 2022

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.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Failed ⬇️0.2% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.54% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.24% ⬆️0.35%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] 1ba97a62 ec2-t3-xlarge-us-east-2
[Finished] 1ba97a62 test-mac-arm
[Finished] 1ba97a62 ursa-i9-9960x
[Finished] 1ba97a62 ursa-thinkcentre-m75q
[Finished] 958fbfa5 ec2-t3-xlarge-us-east-2
[Failed] 958fbfa5 test-mac-arm
[Finished] 958fbfa5 ursa-i9-9960x
[Finished] 958fbfa5 ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MIGRATION: [Developer] The merge_arrow_pr script should be able to handle issues on GitHub and JIRA
5 participants