Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 467e726

Browse filesBrowse files
authored
Merge pull request hub4j#1612 from alecharp/feature/filter-check-runs-on-commit
Filter check runs to retrieve from commit
2 parents 2b67f7a + 4df01a0 commit 467e726
Copy full SHA for 467e726

File tree

Expand file treeCollapse file tree

8 files changed

+449
-0
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+449
-0
lines changed

‎src/main/java/org/kohsuke/github/GHRepository.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,29 @@ public PagedIterable<GHCheckRun> getCheckRuns(String ref) throws IOException {
22102210
return new GHCheckRunsIterable(this, request);
22112211
}
22122212

2213+
/**
2214+
* Gets check runs for given ref which validate provided parameters
2215+
*
2216+
* @param ref
2217+
* the Git reference
2218+
* @param params
2219+
* a map of parameters to filter check runs
2220+
* @return check runs for the given ref
2221+
* @throws IOException
2222+
* the io exception
2223+
* @see <a href="https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref">List check runs
2224+
* for a specific ref</a>
2225+
*/
2226+
@Preview(ANTIOPE)
2227+
public PagedIterable<GHCheckRun> getCheckRuns(String ref, Map<String, Object> params) throws IOException {
2228+
GitHubRequest request = root().createRequest()
2229+
.withUrlPath(String.format("/repos/%s/%s/commits/%s/check-runs", getOwnerName(), name, ref))
2230+
.with(params)
2231+
.withPreview(ANTIOPE)
2232+
.build();
2233+
return new GHCheckRunsIterable(this, request);
2234+
}
2235+
22132236
/**
22142237
* Creates a commit status.
22152238
*

‎src/test/java/org/kohsuke/github/GHRepositoryTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHRepositoryTest.java
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,31 @@ public void getCheckRuns() throws Exception {
13441344
}
13451345
}
13461346

1347+
/**
1348+
* Filter out the checks from a reference
1349+
*
1350+
* @throws Exception
1351+
* the exception
1352+
*/
1353+
@Test
1354+
public void getCheckRunsWithParams() throws Exception {
1355+
final int expectedCount = 1;
1356+
// Use github-api repository as it has checks set up
1357+
final Map<String, Object> params = new HashMap<>(1);
1358+
params.put("check_name", "build-only (Java 17)");
1359+
PagedIterable<GHCheckRun> checkRuns = gitHub.getOrganization("hub4j")
1360+
.getRepository("github-api")
1361+
.getCheckRuns("54d60fbb53b4efa19f3081417bfb6a1de30c55e4", params);
1362+
1363+
// Check if the checkruns are all succeeded and if we got all of them
1364+
int checkRunsCount = 0;
1365+
for (GHCheckRun checkRun : checkRuns) {
1366+
assertThat(checkRun.getConclusion(), equalTo(Conclusion.SUCCESS));
1367+
checkRunsCount++;
1368+
}
1369+
assertThat(checkRunsCount, equalTo(expectedCount));
1370+
}
1371+
13471372
/**
13481373
* Gets the last commit status.
13491374
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"avatar_url": "https://avatars.githubusercontent.com/u/54909825?v=4",
3+
"created_at": "2019-09-04T18:12:34Z",
4+
"description": null,
5+
"events_url": "https://api.github.com/orgs/hub4j/events",
6+
"followers": 0,
7+
"following": 0,
8+
"has_organization_projects": true,
9+
"has_repository_projects": true,
10+
"hooks_url": "https://api.github.com/orgs/hub4j/hooks",
11+
"html_url": "https://github.com/hub4j",
12+
"id": 54909825,
13+
"is_verified": false,
14+
"issues_url": "https://api.github.com/orgs/hub4j/issues",
15+
"login": "hub4j",
16+
"members_url": "https://api.github.com/orgs/hub4j/members{/member}",
17+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
18+
"public_gists": 0,
19+
"public_members_url": "https://api.github.com/orgs/hub4j/public_members{/member}",
20+
"public_repos": 1,
21+
"repos_url": "https://api.github.com/orgs/hub4j/repos",
22+
"type": "Organization",
23+
"updated_at": "2020-05-08T21:26:19Z",
24+
"url": "https://api.github.com/orgs/hub4j"
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
{
2+
"allow_forking": true,
3+
"archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
4+
"archived": false,
5+
"assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
6+
"blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
7+
"branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
8+
"clone_url": "https://github.com/hub4j/github-api.git",
9+
"collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
10+
"comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
11+
"commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
12+
"compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
13+
"contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
14+
"contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
15+
"created_at": "2010-04-19T04:13:03Z",
16+
"default_branch": "main",
17+
"deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
18+
"description": "Java API for GitHub",
19+
"disabled": false,
20+
"downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
21+
"events_url": "https://api.github.com/repos/hub4j/github-api/events",
22+
"fork": false,
23+
"forks": 651,
24+
"forks_count": 651,
25+
"forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
26+
"full_name": "hub4j/github-api",
27+
"git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
28+
"git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
29+
"git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
30+
"git_url": "git://github.com/hub4j/github-api.git",
31+
"has_discussions": true,
32+
"has_downloads": true,
33+
"has_issues": true,
34+
"has_pages": true,
35+
"has_projects": true,
36+
"has_wiki": true,
37+
"homepage": "https://github-api.kohsuke.org/",
38+
"hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
39+
"html_url": "https://github.com/hub4j/github-api",
40+
"id": 617210,
41+
"is_template": false,
42+
"issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
43+
"issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
44+
"issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
45+
"keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
46+
"labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
47+
"language": "Java",
48+
"languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
49+
"license": {
50+
"key": "mit",
51+
"name": "MIT License",
52+
"node_id": "MDc6TGljZW5zZTEz",
53+
"spdx_id": "MIT",
54+
"url": "https://api.github.com/licenses/mit"
55+
},
56+
"merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
57+
"milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
58+
"mirror_url": null,
59+
"name": "github-api",
60+
"network_count": 651,
61+
"node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
62+
"notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
63+
"open_issues": 141,
64+
"open_issues_count": 141,
65+
"organization": {
66+
"avatar_url": "https://avatars.githubusercontent.com/u/54909825?v=4",
67+
"events_url": "https://api.github.com/users/hub4j/events{/privacy}",
68+
"followers_url": "https://api.github.com/users/hub4j/followers",
69+
"following_url": "https://api.github.com/users/hub4j/following{/other_user}",
70+
"gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
71+
"gravatar_id": "",
72+
"html_url": "https://github.com/hub4j",
73+
"id": 54909825,
74+
"login": "hub4j",
75+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
76+
"organizations_url": "https://api.github.com/users/hub4j/orgs",
77+
"received_events_url": "https://api.github.com/users/hub4j/received_events",
78+
"repos_url": "https://api.github.com/users/hub4j/repos",
79+
"site_admin": false,
80+
"starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
81+
"subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
82+
"type": "Organization",
83+
"url": "https://api.github.com/users/hub4j"
84+
},
85+
"owner": {
86+
"avatar_url": "https://avatars.githubusercontent.com/u/54909825?v=4",
87+
"events_url": "https://api.github.com/users/hub4j/events{/privacy}",
88+
"followers_url": "https://api.github.com/users/hub4j/followers",
89+
"following_url": "https://api.github.com/users/hub4j/following{/other_user}",
90+
"gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
91+
"gravatar_id": "",
92+
"html_url": "https://github.com/hub4j",
93+
"id": 54909825,
94+
"login": "hub4j",
95+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
96+
"organizations_url": "https://api.github.com/users/hub4j/orgs",
97+
"received_events_url": "https://api.github.com/users/hub4j/received_events",
98+
"repos_url": "https://api.github.com/users/hub4j/repos",
99+
"site_admin": false,
100+
"starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
101+
"subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
102+
"type": "Organization",
103+
"url": "https://api.github.com/users/hub4j"
104+
},
105+
"private": false,
106+
"pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
107+
"pushed_at": "2023-02-01T14:18:09Z",
108+
"releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
109+
"size": 40829,
110+
"ssh_url": "git@github.com:hub4j/github-api.git",
111+
"stargazers_count": 972,
112+
"stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
113+
"statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
114+
"subscribers_count": 48,
115+
"subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
116+
"subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
117+
"svn_url": "https://github.com/hub4j/github-api",
118+
"tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
119+
"teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
120+
"temp_clone_token": null,
121+
"topics": [
122+
"api",
123+
"client-library",
124+
"github",
125+
"github-api",
126+
"github-api-v3",
127+
"java",
128+
"java-api"
129+
],
130+
"trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
131+
"updated_at": "2023-01-30T18:28:31Z",
132+
"url": "https://api.github.com/repos/hub4j/github-api",
133+
"visibility": "public",
134+
"watchers": 972,
135+
"watchers_count": 972,
136+
"web_commit_signoff_required": false
137+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"total_count": 1,
3+
"check_runs": [
4+
{
5+
"id": 514982790,
6+
"node_id": "MDg6Q2hlY2tSdW41MTQ5ODI3OTA=",
7+
"head_sha": "78b9ff49d47daaa158eb373c4e2e040f739df8b9",
8+
"external_id": "5b9ee24e-a4fa-5b0f-9fef-471905f84b41",
9+
"url": "https://api.github.com/repos/hub4j/github-api/check-runs/514982790",
10+
"html_url": "https://github.com/hub4j/github-api/runs/514982790",
11+
"details_url": "https://github.com/hub4j/github-api/runs/514982790",
12+
"status": "completed",
13+
"conclusion": "success",
14+
"started_at": "2020-03-17T21:37:30Z",
15+
"completed_at": "2020-03-17T21:41:01Z",
16+
"output": {
17+
"title": null,
18+
"summary": null,
19+
"text": null,
20+
"annotations_count": 0,
21+
"annotations_url": "https://api.github.com/repos/hub4j/github-api/check-runs/514982790/annotations"
22+
},
23+
"name": "build-only (Java 17)",
24+
"check_suite": {
25+
"id": 528275399
26+
},
27+
"app": {
28+
"id": 15368,
29+
"slug": "github-actions",
30+
"node_id": "MDM6QXBwMTUzNjg=",
31+
"owner": {
32+
"login": "github",
33+
"id": 9919,
34+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
35+
"avatar_url": "https://avatars1.githubusercontent.com/u/9919?v=4",
36+
"gravatar_id": "",
37+
"url": "https://api.github.com/users/github",
38+
"html_url": "https://github.com/github",
39+
"followers_url": "https://api.github.com/users/github/followers",
40+
"following_url": "https://api.github.com/users/github/following{/other_user}",
41+
"gists_url": "https://api.github.com/users/github/gists{/gist_id}",
42+
"starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
43+
"subscriptions_url": "https://api.github.com/users/github/subscriptions",
44+
"organizations_url": "https://api.github.com/users/github/orgs",
45+
"repos_url": "https://api.github.com/users/github/repos",
46+
"events_url": "https://api.github.com/users/github/events{/privacy}",
47+
"received_events_url": "https://api.github.com/users/github/received_events",
48+
"type": "Organization",
49+
"site_admin": false
50+
},
51+
"name": "GitHub Actions",
52+
"description": "Automate your workflow from idea to production",
53+
"external_url": "https://help.github.com/en/actions",
54+
"html_url": "https://github.com/apps/github-actions",
55+
"created_at": "2018-07-30T09:30:17Z",
56+
"updated_at": "2019-12-10T19:04:12Z",
57+
"permissions": {
58+
"actions": "write",
59+
"checks": "write",
60+
"contents": "write",
61+
"deployments": "write",
62+
"issues": "write",
63+
"metadata": "read",
64+
"packages": "write",
65+
"pages": "write",
66+
"pull_requests": "write",
67+
"repository_hooks": "write",
68+
"repository_projects": "write",
69+
"statuses": "write",
70+
"vulnerability_alerts": "read"
71+
},
72+
"events": [
73+
"check_run",
74+
"check_suite",
75+
"create",
76+
"delete",
77+
"deployment",
78+
"deployment_status",
79+
"fork",
80+
"gollum",
81+
"issues",
82+
"issue_comment",
83+
"label",
84+
"milestone",
85+
"page_build",
86+
"project",
87+
"project_card",
88+
"project_column",
89+
"public",
90+
"pull_request",
91+
"pull_request_review",
92+
"pull_request_review_comment",
93+
"push",
94+
"registry_package",
95+
"release",
96+
"repository",
97+
"repository_dispatch",
98+
"status",
99+
"watch"
100+
]
101+
},
102+
"pull_requests": []
103+
}
104+
]
105+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"id": "5d8b3f90-4fb5-4321-b979-b06127d19224",
3+
"name": "orgs_hub4j",
4+
"request": {
5+
"url": "/orgs/hub4j",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github.v3+json"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "orgs_hub4j-1.json",
16+
"headers": {
17+
"Cache-Control": "public, max-age=60, s-maxage=60",
18+
"Content-Security-Policy": "default-src 'none'",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Date": "Wed, 01 Feb 2023 14:50:02 GMT",
21+
"ETag": "W/\"0f5afebb9a43d2439789b5ee913e4b91dd2ee711e15a942b5a85dc8d6ae18dc9\"",
22+
"Last-Modified": "Fri, 08 May 2020 21:26:19 GMT",
23+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
24+
"Server": "GitHub.com",
25+
"Status": "200 OK",
26+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
27+
"Vary": [
28+
"Accept",
29+
"Accept-Encoding, Accept, X-Requested-With"
30+
],
31+
"X-Content-Type-Options": "nosniff",
32+
"X-Frame-Options": "deny",
33+
"X-GitHub-Media-Type": "github.v3; format=json",
34+
"X-GitHub-Request-Id": "CA71:D7EC:186E8A:18D72D:63DA7C19",
35+
"X-RateLimit-Limit": "60",
36+
"X-RateLimit-Remaining": "55",
37+
"X-RateLimit-Reset": "1675263481",
38+
"X-XSS-Protection": "0"
39+
}
40+
},
41+
"uuid": "5d8b3f90-4fb5-4321-b979-b06127d19224",
42+
"persistent": true,
43+
"insertionIndex": 1
44+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.