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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const editEvent = 'edited';
const issuesLabelEvent = 'issues_labeled';
const issuesAssignedEvent = 'issues_assigned';
const pushEvent = 'push';
const pullRequestReviewEvent = 'pr-review';
const pullRequestReviewEvent = 'pr_review';
const checkCompletedEvent = 'check_completed';
const issueCommentCreatedEvent = 'comment_created';

const claCheck = 'cla-check';
const changelogCheck = 'changelog-check';
Expand All @@ -32,6 +33,7 @@ const pullRequestReviewCheck = 'pr-review-check';
const codeOwnerCheck = 'code-owner-check'
const ciFailureCheck = 'ci-failure-check';
const updateWithDevelopCheck = 'update-with-develop-check';
const respondToReviewCheck = 'respond-to-review-check';

const checksWhitelist = {
'oppia-android': {
Expand Down Expand Up @@ -75,7 +77,8 @@ const checksWhitelist = {
[unlabelEvent]: [datastoreLabelCheck],
[pushEvent]: [forcePushCheck],
[pullRequestReviewEvent]: [pullRequestReviewCheck],
[checkCompletedEvent]: [ciFailureCheck]
[checkCompletedEvent]: [ciFailureCheck],
[issueCommentCreatedEvent]: [respondToReviewCheck]
},
'oppiabot': {
[openEvent]: [claCheck],
Expand Down Expand Up @@ -103,6 +106,7 @@ module.exports.issuesAssignedEvent = issuesAssignedEvent;
module.exports.pushEvent = pushEvent;
module.exports.pullRequestReviewEvent = pullRequestReviewEvent;
module.exports.checkCompletedEvent = checkCompletedEvent;
module.exports.issueCommentCreatedEvent = issueCommentCreatedEvent;

module.exports.claCheck = claCheck;
module.exports.changelogCheck = changelogCheck;
Expand All @@ -123,6 +127,7 @@ module.exports.pullRequestReviewCheck = pullRequestReviewCheck;
module.exports.codeOwnerCheck = codeOwnerCheck;
module.exports.ciFailureCheck = ciFailureCheck;
module.exports.updateWithDevelopCheck = updateWithDevelopCheck;
module.exports.respondToReviewCheck = respondToReviewCheck

module.exports.getBlacklistedAuthors = function() {
return blacklistedAuthors;
Expand Down
238 changes: 238 additions & 0 deletions fixtures/pullRequestComment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
{
"name": "issue_comment",
"payload": {
"action": "created",
"issue": {
"url": "https://api.github.com/repos/oppia/oppia/issues/39",
"repository_url": "https://api.github.com/repos/oppia/oppia",
"labels_url": "https://api.github.com/repos/oppia/oppia/issues/39/labels{/name}",
"comments_url": "https://api.github.com/repos/oppia/oppia/issues/39/comments",
"events_url": "https://api.github.com/repos/oppia/oppia/issues/39/events",
"html_url": "https://github.com/oppia/oppia/pull/39",
"id": 676178626,
"node_id": "MDExOlB1bGxSZXF1ZXN0NDY1NTM1MjI4",
"number": 39,
"title": "Changes",
"user": {
"login": "testuser",
"id": 31052489,
"node_id": "MDQ6VXNlcjMxMDUyNDg5",
"avatar_url": "https://avatars1.githubusercontent.com/u/31052489?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/testuser",
"html_url": "https://github.com/testuser",
"followers_url": "https://api.github.com/users/testuser/followers",
"following_url": "https://api.github.com/users/testuser/following{/other_user}",
"gists_url": "https://api.github.com/users/testuser/gists{/gist_id}",
"starred_url": "https://api.github.com/users/testuser/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/testuser/subscriptions",
"organizations_url": "https://api.github.com/users/testuser/orgs",
"repos_url": "https://api.github.com/users/testuser/repos",
"events_url": "https://api.github.com/users/testuser/events{/privacy}",
"received_events_url": "https://api.github.com/users/testuser/received_events",
"type": "User",
"site_admin": false
},
"labels": [
{
"id": 2140127429,
"node_id": "MDU6TGFiZWwyMTQwMTI3NDI5",
"url": "https://api.github.com/repos/testuser/oppia/labels/PR%20CHANGELOG:%20code%20health%20--%20@testuser",
"name": "PR CHANGELOG: code health -- @testuser",
"color": "c5ccf9",
"default": false,
"description": "Optional"
}
],
"state": "open",
"locked": false,
"assignee": null,
"assignees": [],
"milestone": null,
"comments": 20,
"created_at": "2020-08-10T14:26:14Z",
"updated_at": "2020-08-26T14:44:35Z",
"closed_at": null,
"author_association": "OWNER",
"active_lock_reason": null,
"pull_request": {
"url": "https://api.github.com/repos/oppia/oppia/pulls/39",
"html_url": "https://github.com/oppia/oppia/pull/39",
"diff_url": "https://github.com/oppia/oppia/pull/39.diff",
"patch_url": "https://github.com/oppia/oppia/pull/39.patch"
},
"body": "## Overview\r\n<!--\r\nREAD ME FIRST:\r\nPlease answer *both* questions below and check off every point from the Essential Checklist!\r\nIf there is no corresponding issue number, fill in N/A where it says [fill_in_number_here] below in 1.\r\n-->\r\n\r\n1. This PR fixes or fixes part of #[fill_in_number_here].\r\n2. This PR does the following: [Explain here what your PR does and why]\r\n\r\n## Essential Checklist\r\n\r\n- [ ] The PR title starts with \"Fix #bugnum: \", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with \"Fix part of #bugnum: ...\".)\r\n- [ ] The linter/Karma presubmit checks have passed locally on your machine.\r\n- [ ] \"Allow edits from maintainers\" is checked. (See [here](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork) for instructions on how to enable it.)\r\n - This lets reviewers restart your CircleCI tests for you.\r\n- [ ] The PR is made from a branch that's **not** called \"develop\".\r\n\r\n## PR Pointers\r\n\r\n- Oppiabot will notify you when you don't add a PR_CHANGELOG label. If you are unable to do so, please @-mention a code owner (who will be in the Reviewers list), or ask on [Gitter](https://gitter.im/oppia/oppia-chat).\r\n- For what code owners will expect, see the [Code Owner's wiki page](https://github.com/oppia/oppia/wiki/Oppia%27s-code-owners-and-checks-to-be-carried-out-by-developers).\r\n- Make sure your PR follows conventions in the [style guide](https://github.com/oppia/oppia/wiki/Coding-style-guide), otherwise this will lead to review delays\r\n- Never force push. If you do, your PR will be closed.\r\n",
"performed_via_github_app": null
},
"comment": {
"url": "https://api.github.com/repos/oppia/oppia/issues/comments/680925201",
"html_url": "https://github.com/oppia/oppia/pull/39#issuecomment-680925201",
"issue_url": "https://api.github.com/repos/oppia/oppia/issues/39",
"id": 680925201,
"node_id": "MDEyOklzc3VlQ29tbWVudDY4MDkyNTIwMQ==",
"user": {
"login": "testuser",
"id": 31052489,
"node_id": "MDQ6VXNlcjMxMDUyNDg5",
"avatar_url": "https://avatars1.githubusercontent.com/u/31052489?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/testuser",
"html_url": "https://github.com/testuser",
"followers_url": "https://api.github.com/users/testuser/followers",
"following_url": "https://api.github.com/users/testuser/following{/other_user}",
"gists_url": "https://api.github.com/users/testuser/gists{/gist_id}",
"starred_url": "https://api.github.com/users/testuser/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/testuser/subscriptions",
"organizations_url": "https://api.github.com/users/testuser/orgs",
"repos_url": "https://api.github.com/users/testuser/repos",
"events_url": "https://api.github.com/users/testuser/events{/privacy}",
"received_events_url": "https://api.github.com/users/testuser/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2020-08-26T14:44:35Z",
"updated_at": "2020-08-26T14:44:35Z",
"author_association": "OWNER",
"body": "Hi @reviewer1, @reviewer2 PTAL. Thanks!",
"performed_via_github_app": null
},
"repository": {
"id": 173004022,
"node_id": "MDEwOlJlcG9zaXRvcnkxNzMwMDQwMjI=",
"name": "oppia",
"full_name": "oppia/oppia",
"private": false,
"owner": {
"login": "oppia",
"id": 31052489,
"node_id": "MDQ6VXNlcjMxMDUyNDg5",
"avatar_url": "https://avatars1.githubusercontent.com/u/31052489?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/oppia",
"html_url": "https://github.com/oppia",
"followers_url": "https://api.github.com/users/oppia/followers",
"following_url": "https://api.github.com/users/oppia/following{/other_user}",
"gists_url": "https://api.github.com/users/oppia/gists{/gist_id}",
"starred_url": "https://api.github.com/users/oppia/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/oppia/subscriptions",
"organizations_url": "https://api.github.com/users/oppia/orgs",
"repos_url": "https://api.github.com/users/oppia/repos",
"events_url": "https://api.github.com/users/oppia/events{/privacy}",
"received_events_url": "https://api.github.com/users/oppia/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/oppia/oppia",
"description": "Tool for collaboratively building interactive lessons.",
"fork": true,
"url": "https://api.github.com/repos/oppia/oppia",
"forks_url": "https://api.github.com/repos/oppia/oppia/forks",
"keys_url": "https://api.github.com/repos/oppia/oppia/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/oppia/oppia/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/oppia/oppia/teams",
"hooks_url": "https://api.github.com/repos/oppia/oppia/hooks",
"issue_events_url": "https://api.github.com/repos/oppia/oppia/issues/events{/number}",
"events_url": "https://api.github.com/repos/oppia/oppia/events",
"assignees_url": "https://api.github.com/repos/oppia/oppia/assignees{/user}",
"branches_url": "https://api.github.com/repos/oppia/oppia/branches{/branch}",
"tags_url": "https://api.github.com/repos/oppia/oppia/tags",
"blobs_url": "https://api.github.com/repos/oppia/oppia/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/oppia/oppia/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/oppia/oppia/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/oppia/oppia/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/oppia/oppia/statuses/{sha}",
"languages_url": "https://api.github.com/repos/oppia/oppia/languages",
"stargazers_url": "https://api.github.com/repos/oppia/oppia/stargazers",
"contributors_url": "https://api.github.com/repos/oppia/oppia/contributors",
"subscribers_url": "https://api.github.com/repos/oppia/oppia/subscribers",
"subscription_url": "https://api.github.com/repos/oppia/oppia/subscription",
"commits_url": "https://api.github.com/repos/oppia/oppia/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/oppia/oppia/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/oppia/oppia/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/oppia/oppia/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/oppia/oppia/contents/{+path}",
"compare_url": "https://api.github.com/repos/oppia/oppia/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/oppia/oppia/merges",
"archive_url": "https://api.github.com/repos/oppia/oppia/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/oppia/oppia/downloads",
"issues_url": "https://api.github.com/repos/oppia/oppia/issues{/number}",
"pulls_url": "https://api.github.com/repos/oppia/oppia/pulls{/number}",
"milestones_url": "https://api.github.com/repos/oppia/oppia/milestones{/number}",
"notifications_url": "https://api.github.com/repos/oppia/oppia/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/oppia/oppia/labels{/name}",
"releases_url": "https://api.github.com/repos/oppia/oppia/releases{/id}",
"deployments_url": "https://api.github.com/repos/oppia/oppia/deployments",
"created_at": "2019-02-27T23:03:20Z",
"updated_at": "2020-08-10T14:17:19Z",
"pushed_at": "2020-08-11T20:02:08Z",
"git_url": "git://github.com/oppia/oppia.git",
"ssh_url": "git@github.com:oppia/oppia.git",
"clone_url": "https://github.com/oppia/oppia.git",
"svn_url": "https://github.com/oppia/oppia",
"homepage": "https://www.oppia.org",
"size": 147378,
"stargazers_count": 2,
"watchers_count": 2,
"language": "Python",
"has_issues": false,
"has_projects": true,
"has_downloads": false,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 1,
"license": {
"key": "apache-2.0",
"name": "Apache License 2.0",
"spdx_id": "Apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0",
"node_id": "MDc6TGljZW5zZTI="
},
"forks": 0,
"open_issues": 1,
"watchers": 2,
"default_branch": "develop"
},
"organization": {
"login": "oppia",
"id": 11620230,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjExNjIwMjMw",
"url": "https://api.github.com/orgs/oppia",
"repos_url": "https://api.github.com/orgs/oppia/repos",
"events_url": "https://api.github.com/orgs/oppia/events",
"hooks_url": "https://api.github.com/orgs/oppia/hooks",
"issues_url": "https://api.github.com/orgs/oppia/issues",
"members_url": "https://api.github.com/orgs/oppia/members{/member}",
"public_members_url": "https://api.github.com/orgs/oppia/public_members{/member}",
"avatar_url": "https://avatars1.githubusercontent.com/u/11620230?v=4",
"description": ""
},
"sender": {
"login": "testuser",
"id": 31052489,
"node_id": "MDQ6VXNlcjMxMDUyNDg5",
"avatar_url": "https://avatars1.githubusercontent.com/u/31052489?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/testuser",
"html_url": "https://github.com/testuser",
"followers_url": "https://api.github.com/users/testuser/followers",
"following_url": "https://api.github.com/users/testuser/following{/other_user}",
"gists_url": "https://api.github.com/users/testuser/gists{/gist_id}",
"starred_url": "https://api.github.com/users/testuser/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/testuser/subscriptions",
"organizations_url": "https://api.github.com/users/testuser/orgs",
"repos_url": "https://api.github.com/users/testuser/repos",
"events_url": "https://api.github.com/users/testuser/events{/privacy}",
"received_events_url": "https://api.github.com/users/testuser/received_events",
"type": "User",
"site_admin": false
},
"installation": {
"id": 6909030,
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uNjkwOTAzMA=="
}
}
}
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ const runChecks = async (context, checkEvent) => {
case constants.updateWithDevelopCheck:
await checkMergeConflictsModule.pingAllPullRequestsToMergeFromDevelop(context);
break;
case constants.respondToReviewCheck:
await checkPullRequestReviewModule.handleResponseToReview(context);
break;
}
}
}
Expand Down Expand Up @@ -140,6 +143,14 @@ module.exports = (oppiabot) => {
}
});

oppiabot.on('issue_comment.created', async (context) => {
if (checkWhitelistedAccounts(context)) {
// eslint-disable-next-line no-console
console.log('COMMENT CREATED ON ISSUE OR PULL REQUEST...');
await runChecks(context, constants.issueCommentCreatedEvent);
}
})

oppiabot.on('pull_request.opened', async (context) => {
// The oppiabot runs only for repositories belonging to certain
// whitelisted accounts. The whitelisted accounts are stored as an
Expand Down
Loading