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

User Response to Pull Request Review #121

Merged
merged 21 commits into from
Aug 31, 2020

Conversation

jameesjohn
Copy link
Contributor

Explanation

This PR adds checks for user responding to user reviews.
This feature has been tested at jameesjohn/oppia#39.

Checklist

  • I have successfully deployed my own instance of Oppiabot.
    • You can find instructions for doing this here.
  • I have manually tested all the changes made in this PR following the manual tests matrix.

This PR is stacked on #116 and new changes are from 9e51c98

@oppiabot
Copy link

oppiabot bot commented Aug 28, 2020

Hi @jameesjohn. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks!

Copy link
Contributor

@ankita240796 ankita240796 left a comment

Choose a reason for hiding this comment

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

Hi @jameesjohn, took a pass, PTAL. Thanks!

constants.js Outdated
@@ -8,7 +8,9 @@ const editEvent = 'edited';
const issuesLabelEvent = 'issues_labeled';
const issuesAssignedEvent = 'issues_assigned';
const pushEvent = 'push';
const pullRequestReviewEvent = 'pr-review';
Copy link
Contributor

Choose a reason for hiding this comment

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

pr_review just to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -287,6 +288,75 @@ const handlePullRequestReview = async (context) => {
}
};

/**
* This function checks when a pull request gets commented on by the PR author.
Copy link
Contributor

Choose a reason for hiding this comment

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

when a pull request gets commented on by the PR author --> when PR author comments on the pull request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -287,6 +288,75 @@ const handlePullRequestReview = async (context) => {
}
};

/**
* This function checks when a pull request gets commented on by the PR author.
* If pr author comments on the PR asking reviewers please to take a look (ptal),
Copy link
Contributor

Choose a reason for hiding this comment

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

please to take a look (ptal) --> to please take a look (PTAL)

We will need to update wiki as well to have this info and how oppiabot responds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This is contained in the doc, and I believe that will be shared with the dev community.

/**
* This function checks when a pull request gets commented on by the PR author.
* If pr author comments on the PR asking reviewers please to take a look (ptal),
* We check if the reviewers have been assigned and if not, assign them.
Copy link
Contributor

Choose a reason for hiding this comment

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

We check if the reviewers have been assigned and if not, assign them --> the function checks if the reviewers have been assigned and if not, assigns them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

* @type {import('probot').Octokit.IssuesGetResponse}
*/
const pullRequest = context.payload.issue;
const isPullRequest = 'pull_request' in pullRequest;
Copy link
Contributor

Choose a reason for hiding this comment

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

pull_request -> constant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Pause for 3 minutes in case author wants to perform
// the required actions.
await utilityModule.sleep(THREE_MINUTES);
Copy link
Contributor

Choose a reason for hiding this comment

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

One suggestion regarding the 3 minutes thing - we should also add this to the case when we ask author to assign the reviewers if they are the codeowners - I have noticed that the comment pops really quick even when I am about to assign the reviewer. This one to be specific: https://github.com/oppia/oppiabot/blob/master/lib/checkPullRequestLabels.js#L117. You can update it here or in a separate PR as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think the 3 minutes wait time is needed here?
The response here should be immediate I believe.

Copy link
Contributor

Choose a reason for hiding this comment

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

See this for example, I already assigned a reviewer but oppiabot still leaves a comment. So, we can keep the wait time shorter but we should definitely have it. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.
I'll add it in a separate PR where I'll also be adding features for the new default changelog label.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks!

issue_number: updatedPullRequest.number,
assignees: unassignedUsers,
})
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment too - Hi @ .. assigning you since author requested for a review. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure we should still comment here since we are reacting to a comment already made by the pr author.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, makes sense. But let us unassign the author as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

spec/checkPullRequestReviewSpec.js Show resolved Hide resolved
@@ -287,6 +288,76 @@ const handlePullRequestReview = async (context) => {
}
};

/**
* This function checks when PR author comments on the pull request.
Copy link
Contributor

Choose a reason for hiding this comment

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

checks when -> handles the case when a

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -287,6 +288,76 @@ const handlePullRequestReview = async (context) => {
}
};

/**
* This function checks when PR author comments on the pull request.
* If pr author comments on the PR asking reviewers please to take a look (PTAL),
Copy link
Contributor

Choose a reason for hiding this comment

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

please to take a look (PTAL) -> to please take a look (PTAL)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/**
* This function checks when PR author comments on the pull request.
* If pr author comments on the PR asking reviewers please to take a look (PTAL),
* The function checks if the reviewers have been assigned and if not, assigns them.
Copy link
Contributor

Choose a reason for hiding this comment

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

Line too long - break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


const usersInComment = utilityModule.getUsernamesFromText(comment.body);
// Check if assignment was carried out by author.
const assignees = updatedPullRequest.assignees.map((assignee) => assignee.login);
Copy link
Contributor

Choose a reason for hiding this comment

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

Break if line too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

const unassignedUsers = usersInComment.filter((user) =>
!assignees.includes(user)
);
console.log({ unassignedUsers });
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

issue_number: updatedPullRequest.number,
assignees: unassignedUsers,
})
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, makes sense. But let us unassign the author as well.

});
});

it('should assign remaining reviewer', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

reviewer -> reviewers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

spec/checkPullRequestReviewSpec.js Show resolved Hide resolved
});

describe(
'when the comment is from an issue and not a pull request', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

from -> on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


// Pause for 3 minutes in case author wants to perform
// the required actions.
await utilityModule.sleep(THREE_MINUTES);
Copy link
Contributor

Choose a reason for hiding this comment

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

See this for example, I already assigned a reviewer but oppiabot still leaves a comment. So, we can keep the wait time shorter but we should definitely have it. WDYT?

(assignee) => assignee.login === updatedPullRequest.user.login
);
if (authorIsAssigned) {
context.github.issues.removeAssignees(
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment too - we have unassigned you since a review was requested - please make sure all comments are addressed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment should be something like unassigning @author since a re-review was requested - please make sure all comments are addressed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, sg.

});

describe(
'when author asks reviewer to ptal and does not assign them and author is assigned', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Break line - please check the complete file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@ankita240796 ankita240796 left a comment

Choose a reason for hiding this comment

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

Just a few more nits, PTAL. Thanks @jameesjohn!


// Pause for 3 minutes in case author wants to perform
// the required actions.
await utilityModule.sleep(THREE_MINUTES);
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks!

(assignee) => assignee.login === updatedPullRequest.user.login
);
if (authorIsAssigned) {
context.github.issues.removeAssignees(
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, sg.

context.repo({
issue_number: updatedPullRequest.number,
body:
'Unassigning @author since a re-review was requested ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be @{updatedPullRequest.user.login}.

`Unassigning @{author} since a re-review was requested. @{author} Please make sure you have addressed all the review comments. Thanks!'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.
Thanks

Copy link
Contributor

@ankita240796 ankita240796 left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks @jameesjohn!

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

Successfully merging this pull request may close these issues.

None yet

2 participants