ubccpsc310 / classy

Course management and automation.
MIT License
2 stars 3 forks source link

Allow calling the bot on a PR #96

Closed rtholmes closed 1 year ago

rtholmes commented 1 year ago

AutoTest doesn't treat PRs very naturally as students can only comment on commits. While pushes to branches that are on PRs and comments on commits that are in PRs are supported, commenting on the PR itself is not. Either support this, or at least reply saying that requests need to be on commits.

Right now we only listen to commit_comment and push. This would require us to also listen to issue_comment (and check that it is a PR).

https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment

ubccpsc310 commented 1 year ago

Payload when bot invoked on the comment section at the bottom of a PR:

https://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069/pull/1

{
  "action": "created",
  "issue": {
    "url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/1",
    "repository_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069",
    "labels_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/1/labels{/name}",
    "comments_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/1/comments",
    "events_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/1/events",
    "html_url": "https://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069/pull/1",
    "id": 76882,
    "node_id": "MDExOlB1bGxSZXF1ZXN0NDg5OTQ=",
    "number": 1,
    "title": "Failing Test PR",
    "user": {
      "login": "rtholmes",
      "id": 3096,
      "node_id": "MDQ6VXNlcjMwOTY=",
      "avatar_url": "https://avatars.github.students.cs.ubc.ca/u/3096?",
      "gravatar_id": "",
      "url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes",
      "html_url": "https://github.students.cs.ubc.ca/rtholmes",
      "followers_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/followers",
      "following_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/following{/other_user}",
      "gists_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/gists{/gist_id}",
      "starred_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/starred{/owner}{/repo}",
      "subscriptions_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/subscriptions",
      "organizations_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/orgs",
      "repos_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/repos",
      "events_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/events{/privacy}",
      "received_events_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/received_events",
      "type": "User",
      "site_admin": false,
      "ldap_dn": "uid=rtholmes,ou=People,dc=students,dc=cs,dc=ubc,dc=ca"
    },
    "labels": [],
    "state": "open",
    "locked": false,
    "assignee": null,
    "assignees": [],
    "milestone": null,
    "comments": 2,
    "created_at": "2023-02-08T17:08:34Z",
    "updated_at": "2023-02-08T17:26:04Z",
    "closed_at": null,
    "author_association": "NONE",
    "active_lock_reason": null,
    "draft": false,
    "pull_request": {
      "url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/pulls/1",
      "html_url": "https://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069/pull/1",
      "diff_url": "https://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069/pull/1.diff",
      "patch_url": "https://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069/pull/1.patch",
      "merged_at": null
    },
    "body": null,
    "reactions": {
      "url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/1/reactions",
      "total_count": 0,
      "+1": 0,
      "-1": 0,
      "laugh": 0,
      "hooray": 0,
      "confused": 0,
      "heart": 0,
      "rocket": 0,
      "eyes": 0
    },
    "timeline_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/1/timeline",
    "performed_via_github_app": null,
    "state_reason": null
  },
  "comment": {
    "url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/comments/35122",
    "html_url": "https://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069/pull/1#issuecomment-35122",
    "issue_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/1",
    "id": 35122,
    "node_id": "MDEyOklzc3VlQ29tbWVudDM1MTIy",
    "user": {
      "login": "rtholmes",
      "id": 3096,
      "node_id": "MDQ6VXNlcjMwOTY=",
      "avatar_url": "https://avatars.github.students.cs.ubc.ca/u/3096?",
      "gravatar_id": "",
      "url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes",
      "html_url": "https://github.students.cs.ubc.ca/rtholmes",
      "followers_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/followers",
      "following_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/following{/other_user}",
      "gists_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/gists{/gist_id}",
      "starred_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/starred{/owner}{/repo}",
      "subscriptions_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/subscriptions",
      "organizations_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/orgs",
      "repos_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/repos",
      "events_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/events{/privacy}",
      "received_events_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/received_events",
      "type": "User",
      "site_admin": false,
      "ldap_dn": "uid=rtholmes,ou=People,dc=students,dc=cs,dc=ubc,dc=ca"
    },
    "created_at": "2023-02-08T17:26:04Z",
    "updated_at": "2023-02-08T17:26:04Z",
    "author_association": "NONE",
    "body": "@310-bot #check",
    "reactions": {
      "url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/comments/35122/reactions",
      "total_count": 0,
      "+1": 0,
      "-1": 0,
      "laugh": 0,
      "hooray": 0,
      "confused": 0,
      "heart": 0,
      "rocket": 0,
      "eyes": 0
    },
    "performed_via_github_app": null
  },
  "repository": {
    "id": 80346,
    "node_id": "MDEwOlJlcG9zaXRvcnk4MDM0Ng==",
    "name": "project_team069",
    "full_name": "CPSC310-2022W-T2/project_team069",
    "private": true,
    "owner": {
      "login": "CPSC310-2022W-T2",
      "id": 22800,
      "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyODAw",
      "avatar_url": "https://avatars.github.students.cs.ubc.ca/u/22800?",
      "gravatar_id": "",
      "url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2",
      "html_url": "https://github.students.cs.ubc.ca/CPSC310-2022W-T2",
      "followers_url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2/followers",
      "following_url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2/following{/other_user}",
      "gists_url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2/gists{/gist_id}",
      "starred_url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2/starred{/owner}{/repo}",
      "subscriptions_url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2/subscriptions",
      "organizations_url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2/orgs",
      "repos_url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2/repos",
      "events_url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2/events{/privacy}",
      "received_events_url": "https://github.students.cs.ubc.ca/api/v3/users/CPSC310-2022W-T2/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "html_url": "https://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069",
    "description": null,
    "fork": false,
    "url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069",
    "forks_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/forks",
    "keys_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/keys{/key_id}",
    "collaborators_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/collaborators{/collaborator}",
    "teams_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/teams",
    "hooks_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/hooks",
    "issue_events_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/events{/number}",
    "events_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/events",
    "assignees_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/assignees{/user}",
    "branches_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/branches{/branch}",
    "tags_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/tags",
    "blobs_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/git/blobs{/sha}",
    "git_tags_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/git/tags{/sha}",
    "git_refs_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/git/refs{/sha}",
    "trees_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/git/trees{/sha}",
    "statuses_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/statuses/{sha}",
    "languages_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/languages",
    "stargazers_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/stargazers",
    "contributors_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/contributors",
    "subscribers_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/subscribers",
    "subscription_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/subscription",
    "commits_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/commits{/sha}",
    "git_commits_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/git/commits{/sha}",
    "comments_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/comments{/number}",
    "issue_comment_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues/comments{/number}",
    "contents_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/contents/{+path}",
    "compare_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/compare/{base}...{head}",
    "merges_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/merges",
    "archive_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/{archive_format}{/ref}",
    "downloads_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/downloads",
    "issues_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/issues{/number}",
    "pulls_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/pulls{/number}",
    "milestones_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/milestones{/number}",
    "notifications_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/notifications{?since,all,participating}",
    "labels_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/labels{/name}",
    "releases_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/releases{/id}",
    "deployments_url": "https://github.students.cs.ubc.ca/api/v3/repos/CPSC310-2022W-T2/project_team069/deployments",
    "created_at": "2023-01-24T03:29:42Z",
    "updated_at": "2023-01-24T03:29:58Z",
    "pushed_at": "2023-02-08T17:08:34Z",
    "git_url": "git://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069.git",
    "ssh_url": "git@github.students.cs.ubc.ca:CPSC310-2022W-T2/project_team069.git",
    "clone_url": "https://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069.git",
    "svn_url": "https://github.students.cs.ubc.ca/CPSC310-2022W-T2/project_team069",
    "homepage": null,
    "size": 4067,
    "stargazers_count": 0,
    "watchers_count": 0,
    "language": "TypeScript",
    "has_issues": true,
    "has_projects": true,
    "has_downloads": false,
    "has_wiki": false,
    "has_pages": false,
    "forks_count": 0,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 1,
    "license": null,
    "allow_forking": false,
    "is_template": false,
    "web_commit_signoff_required": false,
    "topics": [],
    "visibility": "private",
    "forks": 0,
    "open_issues": 1,
    "watchers": 0,
    "default_branch": "main"
  },
  "organization": {
    "login": "CPSC310-2022W-T2",
    "id": 22800,
    "node_id": "MDEyOk9yZ2FuaXphdGlvbjIyODAw",
    "url": "https://github.students.cs.ubc.ca/api/v3/orgs/CPSC310-2022W-T2",
    "repos_url": "https://github.students.cs.ubc.ca/api/v3/orgs/CPSC310-2022W-T2/repos",
    "events_url": "https://github.students.cs.ubc.ca/api/v3/orgs/CPSC310-2022W-T2/events",
    "hooks_url": "https://github.students.cs.ubc.ca/api/v3/orgs/CPSC310-2022W-T2/hooks",
    "issues_url": "https://github.students.cs.ubc.ca/api/v3/orgs/CPSC310-2022W-T2/issues",
    "members_url": "https://github.students.cs.ubc.ca/api/v3/orgs/CPSC310-2022W-T2/members{/member}",
    "public_members_url": "https://github.students.cs.ubc.ca/api/v3/orgs/CPSC310-2022W-T2/public_members{/member}",
    "avatar_url": "https://avatars.github.students.cs.ubc.ca/u/22800?",
    "description": null
  },
  "enterprise": {
    "id": 1,
    "slug": "university-of-british-columbia",
    "name": "University of British Columbia",
    "node_id": "MDEwOkVudGVycHJpc2Ux",
    "avatar_url": "https://avatars.github.students.cs.ubc.ca/b/1?",
    "description": "",
    "website_url": "https://www.cs.ubc.ca/",
    "html_url": "https://github.students.cs.ubc.ca/enterprises/university-of-british-columbia",
    "created_at": "2019-04-11T06:27:07Z",
    "updated_at": "2022-06-02T12:55:11Z"
  },
  "sender": {
    "login": "rtholmes",
    "id": 3096,
    "node_id": "MDQ6VXNlcjMwOTY=",
    "avatar_url": "https://avatars.github.students.cs.ubc.ca/u/3096?",
    "gravatar_id": "",
    "url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes",
    "html_url": "https://github.students.cs.ubc.ca/rtholmes",
    "followers_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/followers",
    "following_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/following{/other_user}",
    "gists_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/gists{/gist_id}",
    "starred_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/starred{/owner}{/repo}",
    "subscriptions_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/subscriptions",
    "organizations_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/orgs",
    "repos_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/repos",
    "events_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/events{/privacy}",
    "received_events_url": "https://github.students.cs.ubc.ca/api/v3/users/rtholmes/received_events",
    "type": "User",
    "site_admin": false,
    "ldap_dn": "uid=rtholmes,ou=People,dc=students,dc=cs,dc=ubc,dc=ca"
  }
}
ubccpsc310 commented 1 year ago

From the payload above we can see that these comments are not attached to a specific commit, so we just can't process them. But we can return a warning.