From 4c7b9ae07dbf043fbf8dab5bb5c37f118d3d6749 Mon Sep 17 00:00:00 2001 From: Alex Mukho Date: Mon, 18 Mar 2019 18:15:03 +0200 Subject: [PATCH] check_run and check_suite webhooks support --- github/github.go | 10 + github/github_test.go | 20 ++ github/payload.go | 367 +++++++++++++++++++++++++++++++ testdata/github/check-run.json | 230 +++++++++++++++++++ testdata/github/check-suite.json | 194 ++++++++++++++++ 5 files changed, 821 insertions(+) create mode 100644 testdata/github/check-run.json create mode 100644 testdata/github/check-suite.json diff --git a/github/github.go b/github/github.go index cc8d3e7..9287eb5 100644 --- a/github/github.go +++ b/github/github.go @@ -28,6 +28,8 @@ type Event string // GitHub hook types const ( + CheckRunEvent Event = "check_run" + CheckSuiteEvent Event = "check_suite" CommitCommentEvent Event = "commit_comment" CreateEvent Event = "create" DeleteEvent Event = "delete" @@ -162,6 +164,14 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) } switch gitHubEvent { + case CheckRunEvent: + var pl CheckRunPayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err + case CheckSuiteEvent: + var pl CheckSuitePayload + err = json.Unmarshal([]byte(payload), &pl) + return pl, err case CommitCommentEvent: var pl CommitCommentPayload err = json.Unmarshal([]byte(payload), &pl) diff --git a/github/github_test.go b/github/github_test.go index 122d562..5ffa98a 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -133,6 +133,26 @@ func TestWebhooks(t *testing.T) { filename string headers http.Header }{ + { + name: "CheckRunEvent", + event: CheckRunEvent, + typ: CheckRunPayload{}, + filename: "../testdata/github/check-run.json", + headers: http.Header{ + "X-Github-Event": []string{"check_run"}, + "X-Hub-Signature": []string{"sha1=229f4920493b455398168cd86dc6b366064bdf3f"}, + }, + }, + { + name: "CheckSuiteEvent", + event: CheckSuiteEvent, + typ: CheckSuitePayload{}, + filename: "../testdata/github/check-suite.json", + headers: http.Header{ + "X-Github-Event": []string{"check_suite"}, + "X-Hub-Signature": []string{"sha1=250ad5a340f8d91e67dc5682342f3190fd2006a1"}, + }, + }, { name: "CommitCommentEvent", event: CommitCommentEvent, diff --git a/github/payload.go b/github/payload.go index 69d0c77..47bd61b 100644 --- a/github/payload.go +++ b/github/payload.go @@ -2,6 +2,373 @@ package github import "time" +// CheckRunPayload contains the information for GitHub's check_run hook event +type CheckRunPayload struct { + Action string `json:"action"` + CheckRun struct { + ID int64 `json:"id"` + Name string `json:"name"` + HeadSHA string `json:"head_sha"` + Status string `json:"status"` + Conclusion string `json:"conclusion"` + URL string `json:"url"` + HtmlURL string `json:"html_url"` + StarterAt time.Time `json:"started_at"` + CompletedAt time.Time `json:"completed_at"` + Output struct { + Title string `json:"title"` + Summary string `json:"summary"` + Text string `json:"text"` + AnnotationsCount int64 `json:"annotations_count"` + AnnotationsURL string `json:"annotations_url"` + } + CheckSuite struct { + ID int64 `json:"id"` + HeadBranch string `json:"head_branch"` + HeadSHA string `json:"head_sha"` + Status string `json:"status"` + Conclusion string `json:"conclusion"` + URL string `json:"url"` + Before string `json:"before"` + After string `json:"after"` + PullRequests []PullRequestPayload `json:"pull_requests"` + App struct { + ID int64 `json:"id"` + Owner struct { + Login string `json:"login"` + ID int64 `json:"id"` + AvatarURL string `json:"avatar_url"` + GravatarID string `json:"gravatar_id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + FollowersURL string `json:"followers_url"` + FollowingURL string `json:"following_url"` + GistsURL string `json:"gists_url"` + StarredURL string `json:"starred_url"` + SubscriptionsURL string `json:"subscriptions_url"` + OrganizationsURL string `json:"organizations_url"` + ReposURL string `json:"repos_url"` + EventsURL string `json:"events_url"` + ReceivedEventsURL string `json:"received_events_url"` + Type string `json:"type"` + SiteAdmin bool `json:"site_admin"` + } `json:"owner"` + Name string `json:"name"` + Description string `json:"description"` + ExternalURL string `json:"external_url"` + HtmlURL string `json:"html_url"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + } `json:"app"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + } `json:"check_suite"` + App struct { + ID int64 `json:"id"` + Owner struct { + Login string `json:"login"` + ID int64 `json:"id"` + AvatarURL string `json:"avatar_url"` + GravatarID string `json:"gravatar_id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + FollowersURL string `json:"followers_url"` + FollowingURL string `json:"following_url"` + GistsURL string `json:"gists_url"` + StarredURL string `json:"starred_url"` + SubscriptionsURL string `json:"subscriptions_url"` + OrganizationsURL string `json:"organizations_url"` + ReposURL string `json:"repos_url"` + EventsURL string `json:"events_url"` + ReceivedEventsURL string `json:"received_events_url"` + Type string `json:"type"` + SiteAdmin bool `json:"site_admin"` + } `json:"owner"` + Name string `json:"name"` + Description string `json:"description"` + ExternalURL string `json:"external_url"` + HtmlURL string `json:"html_url"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + } `json:"app"` + PullRequests []PullRequestPayload `json:"pull_requests"` + } `json:"check_run"` + Repository struct { + ID int64 `json:"id"` + Name string `json:"name"` + FullName string `json:"full_name"` + Owner struct { + Login string `json:"login"` + ID int64 `json:"id"` + AvatarURL string `json:"avatar_url"` + GravatarID string `json:"gravatar_id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + FollowersURL string `json:"followers_url"` + FollowingURL string `json:"following_url"` + GistsURL string `json:"gists_url"` + StarredURL string `json:"starred_url"` + SubscriptionsURL string `json:"subscriptions_url"` + OrganizationsURL string `json:"organizations_url"` + ReposURL string `json:"repos_url"` + EventsURL string `json:"events_url"` + ReceivedEventsURL string `json:"received_events_url"` + Type string `json:"type"` + SiteAdmin bool `json:"site_admin"` + } `json:"owner"` + Private bool `json:"private"` + HTMLURL string `json:"html_url"` + Description string `json:"description"` + Fork bool `json:"fork"` + URL string `json:"url"` + ForksURL string `json:"forks_url"` + KeysURL string `json:"keys_url"` + CollaboratorsURL string `json:"collaborators_url"` + TeamsURL string `json:"teams_url"` + HooksURL string `json:"hooks_url"` + IssueEventsURL string `json:"issue_events_url"` + EventsURL string `json:"events_url"` + AssigneesURL string `json:"assignees_url"` + BranchesURL string `json:"branches_url"` + TagsURL string `json:"tags_url"` + BlobsURL string `json:"blobs_url"` + GitTagsURL string `json:"git_tags_url"` + GitRefsURL string `json:"git_refs_url"` + TreesURL string `json:"trees_url"` + StatusesURL string `json:"statuses_url"` + LanguagesURL string `json:"languages_url"` + StargazersURL string `json:"stargazers_url"` + ContributorsURL string `json:"contributors_url"` + SubscribersURL string `json:"subscribers_url"` + SubscriptionURL string `json:"subscription_url"` + CommitsURL string `json:"commits_url"` + GitCommitsURL string `json:"git_commits_url"` + CommentsURL string `json:"comments_url"` + IssueCommentURL string `json:"issue_comment_url"` + ContentsURL string `json:"contents_url"` + CompareURL string `json:"compare_url"` + MergesURL string `json:"merges_url"` + ArchiveURL string `json:"archive_url"` + DownloadsURL string `json:"downloads_url"` + IssuesURL string `json:"issues_url"` + PullsURL string `json:"pulls_url"` + MilestonesURL string `json:"milestones_url"` + NotificationsURL string `json:"notifications_url"` + LabelsURL string `json:"labels_url"` + ReleasesURL string `json:"releases_url"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + PushedAt time.Time `json:"pushed_at"` + GitURL string `json:"git_url"` + SSHURL string `json:"ssh_url"` + CloneURL string `json:"clone_url"` + SvnURL string `json:"svn_url"` + Homepage *string `json:"homepage"` + Size int64 `json:"size"` + StargazersCount int64 `json:"stargazers_count"` + WatchersCount int64 `json:"watchers_count"` + Language *string `json:"language"` + HasIssues bool `json:"has_issues"` + HasDownloads bool `json:"has_downloads"` + HasWiki bool `json:"has_wiki"` + HasPages bool `json:"has_pages"` + ForksCount int64 `json:"forks_count"` + MirrorURL *string `json:"mirror_url"` + OpenIssuesCount int64 `json:"open_issues_count"` + Forks int64 `json:"forks"` + OpenIssues int64 `json:"open_issues"` + Watchers int64 `json:"watchers"` + DefaultBranch string `json:"default_branch"` + } `json:"repository"` + Sender struct { + Login string `json:"login"` + ID int64 `json:"id"` + AvatarURL string `json:"avatar_url"` + GravatarID string `json:"gravatar_id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + FollowersURL string `json:"followers_url"` + FollowingURL string `json:"following_url"` + GistsURL string `json:"gists_url"` + StarredURL string `json:"starred_url"` + SubscriptionsURL string `json:"subscriptions_url"` + OrganizationsURL string `json:"organizations_url"` + ReposURL string `json:"repos_url"` + EventsURL string `json:"events_url"` + ReceivedEventsURL string `json:"received_events_url"` + Type string `json:"type"` + SiteAdmin bool `json:"site_admin"` + } `json:"sender"` +} + +// CheckSuitePayload contains the information for GitHub's check_suite hook event +type CheckSuitePayload struct { + Action string `json:"action"` + CheckSuite struct { + ID int64 `json:"id"` + HeadBranch string `json:"head_branch"` + HeadSHA string `json:"head_sha"` + Status string `json:"status"` + Conclusion string `json:"conclusion"` + URL string `json:"url"` + Before string `json:"before"` + After string `json:"after"` + PullRequests []PullRequestPayload `json:"pull_requests"` + App struct { + ID int64 `json:"id"` + Owner struct { + Login string `json:"login"` + ID int64 `json:"id"` + AvatarURL string `json:"avatar_url"` + GravatarID string `json:"gravatar_id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + FollowersURL string `json:"followers_url"` + FollowingURL string `json:"following_url"` + GistsURL string `json:"gists_url"` + StarredURL string `json:"starred_url"` + SubscriptionsURL string `json:"subscriptions_url"` + OrganizationsURL string `json:"organizations_url"` + ReposURL string `json:"repos_url"` + EventsURL string `json:"events_url"` + ReceivedEventsURL string `json:"received_events_url"` + Type string `json:"type"` + SiteAdmin bool `json:"site_admin"` + } `json:"owner"` + Name string `json:"name"` + Description string `json:"description"` + ExternalURL string `json:"external_url"` + HtmlURL string `json:"html_url"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` + } `json:"app"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + LatestCheckRunsCount int64 `json:"latest_check_runs_count"` + CheckRunsURL string `json:"check_runs_url"` + HeadCommit struct { + ID string `json:"id"` + TreeID string `json:"tree_id"` + Message string `json:"message"` + Timestamp time.Time `json:"timestamp"` + Author struct { + Name string `json:"name"` + Email string `json:"email"` + } `json:"author"` + Commiter struct { + Name string `json:"name"` + Email string `json:"email"` + } `json:"commiter"` + } `json:"head_commit"` + } `json:"check_suite"` + Repository struct { + ID int64 `json:"id"` + Name string `json:"name"` + FullName string `json:"full_name"` + Owner struct { + Login string `json:"login"` + ID int64 `json:"id"` + AvatarURL string `json:"avatar_url"` + GravatarID string `json:"gravatar_id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + FollowersURL string `json:"followers_url"` + FollowingURL string `json:"following_url"` + GistsURL string `json:"gists_url"` + StarredURL string `json:"starred_url"` + SubscriptionsURL string `json:"subscriptions_url"` + OrganizationsURL string `json:"organizations_url"` + ReposURL string `json:"repos_url"` + EventsURL string `json:"events_url"` + ReceivedEventsURL string `json:"received_events_url"` + Type string `json:"type"` + SiteAdmin bool `json:"site_admin"` + } `json:"owner"` + Private bool `json:"private"` + HTMLURL string `json:"html_url"` + Description string `json:"description"` + Fork bool `json:"fork"` + URL string `json:"url"` + ForksURL string `json:"forks_url"` + KeysURL string `json:"keys_url"` + CollaboratorsURL string `json:"collaborators_url"` + TeamsURL string `json:"teams_url"` + HooksURL string `json:"hooks_url"` + IssueEventsURL string `json:"issue_events_url"` + EventsURL string `json:"events_url"` + AssigneesURL string `json:"assignees_url"` + BranchesURL string `json:"branches_url"` + TagsURL string `json:"tags_url"` + BlobsURL string `json:"blobs_url"` + GitTagsURL string `json:"git_tags_url"` + GitRefsURL string `json:"git_refs_url"` + TreesURL string `json:"trees_url"` + StatusesURL string `json:"statuses_url"` + LanguagesURL string `json:"languages_url"` + StargazersURL string `json:"stargazers_url"` + ContributorsURL string `json:"contributors_url"` + SubscribersURL string `json:"subscribers_url"` + SubscriptionURL string `json:"subscription_url"` + CommitsURL string `json:"commits_url"` + GitCommitsURL string `json:"git_commits_url"` + CommentsURL string `json:"comments_url"` + IssueCommentURL string `json:"issue_comment_url"` + ContentsURL string `json:"contents_url"` + CompareURL string `json:"compare_url"` + MergesURL string `json:"merges_url"` + ArchiveURL string `json:"archive_url"` + DownloadsURL string `json:"downloads_url"` + IssuesURL string `json:"issues_url"` + PullsURL string `json:"pulls_url"` + MilestonesURL string `json:"milestones_url"` + NotificationsURL string `json:"notifications_url"` + LabelsURL string `json:"labels_url"` + ReleasesURL string `json:"releases_url"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + PushedAt time.Time `json:"pushed_at"` + GitURL string `json:"git_url"` + SSHURL string `json:"ssh_url"` + CloneURL string `json:"clone_url"` + SvnURL string `json:"svn_url"` + Homepage *string `json:"homepage"` + Size int64 `json:"size"` + StargazersCount int64 `json:"stargazers_count"` + WatchersCount int64 `json:"watchers_count"` + Language *string `json:"language"` + HasIssues bool `json:"has_issues"` + HasDownloads bool `json:"has_downloads"` + HasWiki bool `json:"has_wiki"` + HasPages bool `json:"has_pages"` + ForksCount int64 `json:"forks_count"` + MirrorURL *string `json:"mirror_url"` + OpenIssuesCount int64 `json:"open_issues_count"` + Forks int64 `json:"forks"` + OpenIssues int64 `json:"open_issues"` + Watchers int64 `json:"watchers"` + DefaultBranch string `json:"default_branch"` + } `json:"repository"` + Sender struct { + Login string `json:"login"` + ID int64 `json:"id"` + AvatarURL string `json:"avatar_url"` + GravatarID string `json:"gravatar_id"` + URL string `json:"url"` + HTMLURL string `json:"html_url"` + FollowersURL string `json:"followers_url"` + FollowingURL string `json:"following_url"` + GistsURL string `json:"gists_url"` + StarredURL string `json:"starred_url"` + SubscriptionsURL string `json:"subscriptions_url"` + OrganizationsURL string `json:"organizations_url"` + ReposURL string `json:"repos_url"` + EventsURL string `json:"events_url"` + ReceivedEventsURL string `json:"received_events_url"` + Type string `json:"type"` + SiteAdmin bool `json:"site_admin"` + } `json:"sender"` +} + // CommitCommentPayload contains the information for GitHub's commit_comment hook event type CommitCommentPayload struct { Action string `json:"action"` diff --git a/testdata/github/check-run.json b/testdata/github/check-run.json new file mode 100644 index 0000000..4e5ecff --- /dev/null +++ b/testdata/github/check-run.json @@ -0,0 +1,230 @@ +{ + "action": "rerequested", + "check_run": { + "id": 4, + "head_sha": "d6fde92930d4715a2b49857d24b940956b26d2d3", + "external_id": "", + "url": "https://api.github.com/repos/github/hello-world/check-runs/4", + "html_url": "http://github.com/github/hello-world/runs/4", + "status": "completed", + "conclusion": "neutral", + "started_at": "2018-05-04T01:14:52Z", + "completed_at": "2018-05-04T01:14:52Z", + "output": { + "title": "Report", + "summary": "It's all good.", + "text": "Minus odio facilis repudiandae. Soluta odit aut amet magni nobis. Et voluptatibus ex dolorem et eum.", + "annotations_count": 2, + "annotations_url": "https://api.github.com/repos/github/hello-world/check-runs/4/annotations" + }, + "name": "randscape", + "check_suite": { + "id": 5, + "head_branch": "master", + "head_sha": "d6fde92930d4715a2b49857d24b940956b26d2d3", + "status": "completed", + "conclusion": "neutral", + "url": "https://api.github.com/repos/github/hello-world/check-suites/5", + "before": "146e867f55c26428e5f9fade55a9bbf5e95a7912", + "after": "d6fde92930d4715a2b49857d24b940956b26d2d3", + "pull_requests": [ + + ], + "app": { + "id": 2, + "node_id": "MDExOkludGVncmF0aW9uMQ==", + "owner": { + "login": "github", + "id": 340, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", + "avatar_url": "http://alambic.github.com/avatars/u/340?", + "gravatar_id": "", + "url": "https://api.github.com/users/github", + "html_url": "http://github.com/github", + "followers_url": "https://api.github.com/users/github/followers", + "following_url": "https://api.github.com/users/github/following{/other_user}", + "gists_url": "https://api.github.com/users/github/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github/subscriptions", + "organizations_url": "https://api.github.com/users/github/orgs", + "repos_url": "https://api.github.com/users/github/repos", + "events_url": "https://api.github.com/users/github/events{/privacy}", + "received_events_url": "https://api.github.com/users/github/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Super Duper", + "description": null, + "external_url": "http://super-duper.example.com", + "html_url": "http://github.com/apps/super-duper", + "created_at": "2018-04-25 20:42:10", + "updated_at": "2018-04-25 20:42:10" + }, + "created_at": "2018-05-04T01:14:52Z", + "updated_at": "2018-05-04T01:14:52Z" + }, + "app": { + "id": 2, + "node_id": "MDExOkludGVncmF0aW9uMQ==", + "owner": { + "login": "github", + "id": 340, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", + "avatar_url": "http://alambic.github.com/avatars/u/340?", + "gravatar_id": "", + "url": "https://api.github.com/users/github", + "html_url": "http://github.com/github", + "followers_url": "https://api.github.com/users/github/followers", + "following_url": "https://api.github.com/users/github/following{/other_user}", + "gists_url": "https://api.github.com/users/github/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github/subscriptions", + "organizations_url": "https://api.github.com/users/github/orgs", + "repos_url": "https://api.github.com/users/github/repos", + "events_url": "https://api.github.com/users/github/events{/privacy}", + "received_events_url": "https://api.github.com/users/github/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Super Duper", + "description": null, + "external_url": "http://super-duper.example.com", + "html_url": "http://github.com/apps/super-duper", + "created_at": "2018-04-25 20:42:10", + "updated_at": "2018-04-25 20:42:10" + }, + "pull_requests": [ + + ] + }, + "repository": { + "id": 526, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "hello-world", + "full_name": "github/hello-world", + "owner": { + "login": "github", + "id": 340, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "http://alambic.github.com/avatars/u/340?", + "gravatar_id": "", + "url": "https://api.github.com/users/github", + "html_url": "http://github.com/github", + "followers_url": "https://api.github.com/users/github/followers", + "following_url": "https://api.github.com/users/github/following{/other_user}", + "gists_url": "https://api.github.com/users/github/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github/subscriptions", + "organizations_url": "https://api.github.com/users/github/orgs", + "repos_url": "https://api.github.com/users/github/repos", + "events_url": "https://api.github.com/users/github/events{/privacy}", + "received_events_url": "https://api.github.com/users/github/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "http://github.com/github/hello-world", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/github/hello-world", + "forks_url": "https://api.github.com/repos/github/hello-world/forks", + "keys_url": "https://api.github.com/repos/github/hello-world/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github/hello-world/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github/hello-world/teams", + "hooks_url": "https://api.github.com/repos/github/hello-world/hooks", + "issue_events_url": "https://api.github.com/repos/github/hello-world/issues/events{/number}", + "events_url": "https://api.github.com/repos/github/hello-world/events", + "assignees_url": "https://api.github.com/repos/github/hello-world/assignees{/user}", + "branches_url": "https://api.github.com/repos/github/hello-world/branches{/branch}", + "tags_url": "https://api.github.com/repos/github/hello-world/tags", + "blobs_url": "https://api.github.com/repos/github/hello-world/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github/hello-world/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github/hello-world/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github/hello-world/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github/hello-world/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github/hello-world/languages", + "stargazers_url": "https://api.github.com/repos/github/hello-world/stargazers", + "contributors_url": "https://api.github.com/repos/github/hello-world/contributors", + "subscribers_url": "https://api.github.com/repos/github/hello-world/subscribers", + "subscription_url": "https://api.github.com/repos/github/hello-world/subscription", + "commits_url": "https://api.github.com/repos/github/hello-world/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github/hello-world/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github/hello-world/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github/hello-world/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github/hello-world/contents/{+path}", + "compare_url": "https://api.github.com/repos/github/hello-world/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github/hello-world/merges", + "archive_url": "https://api.github.com/repos/github/hello-world/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github/hello-world/downloads", + "issues_url": "https://api.github.com/repos/github/hello-world/issues{/number}", + "pulls_url": "https://api.github.com/repos/github/hello-world/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github/hello-world/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github/hello-world/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github/hello-world/labels{/name}", + "releases_url": "https://api.github.com/repos/github/hello-world/releases{/id}", + "deployments_url": "https://api.github.com/repos/github/hello-world/deployments", + "created_at": "2018-04-25T20:42:10Z", + "updated_at": "2018-04-25T20:43:34Z", + "pushed_at": "2018-05-04T01:14:47Z", + "git_url": "git://github.com/github/hello-world.git", + "ssh_url": "ssh://git@localhost:3035/github/hello-world.git", + "clone_url": "http://github.com/github/hello-world.git", + "svn_url": "http://github.com/github/hello-world", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 3, + "license": null, + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "master" + }, + "organization": { + "login": "github", + "id": 340, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM4MzAyODk5", + "url": "https://api.github.com/orgs/github", + "repos_url": "https://api.github.com/orgs/github/repos", + "events_url": "https://api.github.com/orgs/github/events", + "hooks_url": "https://api.github.com/orgs/github/hooks", + "issues_url": "https://api.github.com/orgs/github/issues", + "members_url": "https://api.github.com/orgs/github/members{/member}", + "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", + "avatar_url": "http://alambic.github.com/avatars/u/340?", + "description": "How people build software." + }, + "sender": { + "login": "octocat", + "id": 5346, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "http://alambic.github.com/avatars/u/5346?", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "http://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 1 + } +} \ No newline at end of file diff --git a/testdata/github/check-suite.json b/testdata/github/check-suite.json new file mode 100644 index 0000000..9fd400d --- /dev/null +++ b/testdata/github/check-suite.json @@ -0,0 +1,194 @@ +{ + "action": "requested", + "check_suite": { + "id": 5, + "head_branch": "master", + "head_sha": "d6fde92930d4715a2b49857d24b940956b26d2d3", + "status": "completed", + "conclusion": "neutral", + "url": "https://api.github.com/repos/github/hello-world/check-suites/5", + "before": "146e867f55c26428e5f9fade55a9bbf5e95a7912", + "after": "d6fde92930d4715a2b49857d24b940956b26d2d3", + "pull_requests": [ + + ], + "app": { + "id": 2, + "node_id": "MDExOkludGVncmF0aW9uMQ==", + "owner": { + "login": "github", + "id": 340, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", + "avatar_url": "http://alambic.github.com/avatars/u/340?", + "gravatar_id": "", + "url": "https://api.github.com/users/github", + "html_url": "http://github.com/github", + "followers_url": "https://api.github.com/users/github/followers", + "following_url": "https://api.github.com/users/github/following{/other_user}", + "gists_url": "https://api.github.com/users/github/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github/subscriptions", + "organizations_url": "https://api.github.com/users/github/orgs", + "repos_url": "https://api.github.com/users/github/repos", + "events_url": "https://api.github.com/users/github/events{/privacy}", + "received_events_url": "https://api.github.com/users/github/received_events", + "type": "Organization", + "site_admin": false + }, + "name": "Super Duper", + "description": null, + "external_url": "http://super-duper.example.com", + "html_url": "http://github.com/apps/super-duper", + "created_at": "2018-04-25 20:42:10", + "updated_at": "2018-04-25 20:42:10" + }, + "created_at": "2018-05-04T01:14:52Z", + "updated_at": "2018-05-04T01:14:52Z", + "latest_check_runs_count": 1, + "check_runs_url": "https://api.github.com/repos/github/hello-world/check-suites/5/check-runs", + "head_commit": { + "id": "d6fde92930d4715a2b49857d24b940956b26d2d3", + "tree_id": "41a846c7d878d279f11355e23b348e1bb63b89a8", + "message": "Say hello (again) to everybody", + "timestamp": "2018-05-04T01:14:46Z", + "author": { + "name": "octocat", + "email": "octocat@github.com" + }, + "committer": { + "name": "octocat", + "email": "octocat@github.com" + } + } + }, + "repository": { + "id": 526, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "hello-world", + "full_name": "github/hello-world", + "owner": { + "login": "github", + "id": 340, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "http://alambic.github.com/avatars/u/340?", + "gravatar_id": "", + "url": "https://api.github.com/users/github", + "html_url": "http://github.com/github", + "followers_url": "https://api.github.com/users/github/followers", + "following_url": "https://api.github.com/users/github/following{/other_user}", + "gists_url": "https://api.github.com/users/github/gists{/gist_id}", + "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/github/subscriptions", + "organizations_url": "https://api.github.com/users/github/orgs", + "repos_url": "https://api.github.com/users/github/repos", + "events_url": "https://api.github.com/users/github/events{/privacy}", + "received_events_url": "https://api.github.com/users/github/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "http://github.com/github/hello-world", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/github/hello-world", + "forks_url": "https://api.github.com/repos/github/hello-world/forks", + "keys_url": "https://api.github.com/repos/github/hello-world/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/github/hello-world/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/github/hello-world/teams", + "hooks_url": "https://api.github.com/repos/github/hello-world/hooks", + "issue_events_url": "https://api.github.com/repos/github/hello-world/issues/events{/number}", + "events_url": "https://api.github.com/repos/github/hello-world/events", + "assignees_url": "https://api.github.com/repos/github/hello-world/assignees{/user}", + "branches_url": "https://api.github.com/repos/github/hello-world/branches{/branch}", + "tags_url": "https://api.github.com/repos/github/hello-world/tags", + "blobs_url": "https://api.github.com/repos/github/hello-world/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/github/hello-world/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/github/hello-world/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/github/hello-world/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/github/hello-world/statuses/{sha}", + "languages_url": "https://api.github.com/repos/github/hello-world/languages", + "stargazers_url": "https://api.github.com/repos/github/hello-world/stargazers", + "contributors_url": "https://api.github.com/repos/github/hello-world/contributors", + "subscribers_url": "https://api.github.com/repos/github/hello-world/subscribers", + "subscription_url": "https://api.github.com/repos/github/hello-world/subscription", + "commits_url": "https://api.github.com/repos/github/hello-world/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/github/hello-world/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/github/hello-world/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/github/hello-world/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/github/hello-world/contents/{+path}", + "compare_url": "https://api.github.com/repos/github/hello-world/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/github/hello-world/merges", + "archive_url": "https://api.github.com/repos/github/hello-world/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/github/hello-world/downloads", + "issues_url": "https://api.github.com/repos/github/hello-world/issues{/number}", + "pulls_url": "https://api.github.com/repos/github/hello-world/pulls{/number}", + "milestones_url": "https://api.github.com/repos/github/hello-world/milestones{/number}", + "notifications_url": "https://api.github.com/repos/github/hello-world/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/github/hello-world/labels{/name}", + "releases_url": "https://api.github.com/repos/github/hello-world/releases{/id}", + "deployments_url": "https://api.github.com/repos/github/hello-world/deployments", + "created_at": "2018-04-25T20:42:10Z", + "updated_at": "2018-04-25T20:43:34Z", + "pushed_at": "2018-05-04T01:14:47Z", + "git_url": "git://github.com/github/hello-world.git", + "ssh_url": "ssh://git@localhost:3035/github/hello-world.git", + "clone_url": "http://github.com/github/hello-world.git", + "svn_url": "http://github.com/github/hello-world", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 3, + "license": null, + "forks": 0, + "open_issues": 3, + "watchers": 0, + "default_branch": "master" + }, + "organization": { + "login": "github", + "id": 340, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM4MzAyODk5", + "url": "https://api.github.com/orgs/github", + "repos_url": "https://api.github.com/orgs/github/repos", + "events_url": "https://api.github.com/orgs/github/events", + "hooks_url": "https://api.github.com/orgs/github/hooks", + "issues_url": "https://api.github.com/orgs/github/issues", + "members_url": "https://api.github.com/orgs/github/members{/member}", + "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", + "avatar_url": "http://alambic.github.com/avatars/u/340?", + "description": "How people build software." + }, + "sender": { + "login": "octocat", + "id": 5346, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "http://alambic.github.com/avatars/u/5346?", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "http://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 1 + } +} \ No newline at end of file