Skip to content
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
17 changes: 17 additions & 0 deletions src/main/java/org/kohsuke/github/GHCheckRunBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ private GHCheckRunBuilder(GHRepository repo, Requester requester) {
.withUrlPath(repo.getApiTailUrl("check-runs/" + checkId)));
}

/**
* With name.
*
* @param name
* the name
* @param oldName
* the old name
* @return the GH check run builder
*/
public @NonNull GHCheckRunBuilder withName(@CheckForNull String name, String oldName) {
if (oldName == null) {
throw new GHException("Can not update uncreated check run");
}
requester.with("name", name);
return this;
}

/**
* With details URL.
*
Expand Down
57 changes: 57 additions & 0 deletions src/test/java/org/kohsuke/github/GHCheckRunBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.kohsuke.github;

import org.junit.Assert;
import org.junit.Test;
import org.kohsuke.github.GHCheckRun.Status;

Expand Down Expand Up @@ -195,4 +196,60 @@ public void updateCheckRun() throws Exception {
assertThat(checkRun.getOutput().getAnnotationsCount(), equalTo(1));
}

/**
* Update check run with name.
*
* @throws Exception
* the exception
*/
@Test
public void updateCheckRunWithName() throws Exception {
GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks")
.createCheckRun("foo", "89a9ae301e35e667756034fdc933b1fc94f63fc1")
.withStatus(GHCheckRun.Status.IN_PROGRESS)
.withStartedAt(new Date(999_999_000))
.add(new GHCheckRunBuilder.Output("Some Title", "what happened…")
.add(new GHCheckRunBuilder.Annotation("stuff.txt",
1,
GHCheckRun.AnnotationLevel.NOTICE,
"hello to you too").withTitle("Look here")))
.create();
GHCheckRun updated = checkRun.update()
.withStatus(GHCheckRun.Status.COMPLETED)
.withConclusion(GHCheckRun.Conclusion.SUCCESS)
.withCompletedAt(new Date(999_999_999))
.withName("bar", checkRun.getName())
.create();
assertThat(new Date(999_999_000), equalTo(updated.getStartedAt()));
assertThat("bar", equalTo(updated.getName()));
assertThat(checkRun.getOutput().getAnnotationsCount(), equalTo(1));
}

/**
* Update the check run with name exception.
*
* @throws Exception
* the exception
*/
@Test
public void updateCheckRunWithNameException() throws Exception {
snapshotNotAllowed();
GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks")
.createCheckRun("foo", "89a9ae301e35e667756034fdc933b1fc94f63fc1")
.withStatus(GHCheckRun.Status.IN_PROGRESS)
.withStartedAt(new Date(999_999_000))
.add(new GHCheckRunBuilder.Output("Some Title", "what happened…")
.add(new GHCheckRunBuilder.Annotation("stuff.txt",
1,
GHCheckRun.AnnotationLevel.NOTICE,
"hello to you too").withTitle("Look here")))
.create();
Assert.assertThrows(GHException.class,
() -> checkRun.update()
.withStatus(GHCheckRun.Status.COMPLETED)
.withConclusion(GHCheckRun.Conclusion.SUCCESS)
.withCompletedAt(new Date(999_999_999))
.withName("bar", null)
.create());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"id": 89368,
"slug": "ghapi-test-app-3",
"node_id": "MDM6QXBwODkzNjg=",
"owner": {
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j-test-org",
"html_url": "https://github.com/hub4j-test-org",
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"name": "GHApi Test app 3",
"description": "Test app for checks api testing",
"external_url": "http://localhost",
"html_url": "https://github.com/apps/ghapi-test-app-3",
"created_at": "2020-11-19T14:30:34Z",
"updated_at": "2020-11-19T14:30:34Z",
"permissions": {
"checks": "write",
"metadata": "read"
},
"events": [],
"installations_count": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"id": 13064215,
"account": {
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j-test-org",
"html_url": "https://github.com/hub4j-test-org",
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"repository_selection": "selected",
"access_tokens_url": "https://api.github.com/app/installations/13064215/access_tokens",
"repositories_url": "https://api.github.com/installation/repositories",
"html_url": "https://github.com/organizations/hub4j-test-org/settings/installations/13064215",
"app_id": 89368,
"app_slug": "ghapi-test-app-3",
"target_id": 7544739,
"target_type": "Organization",
"permissions": {
"checks": "write",
"metadata": "read"
},
"events": [],
"created_at": "2020-11-19T14:33:27.000Z",
"updated_at": "2020-11-19T14:33:27.000Z",
"single_file_name": null,
"has_multiple_single_files": false,
"single_file_paths": [],
"suspended_by": null,
"suspended_at": null
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"id": 314259932,
"node_id": "MDEwOlJlcG9zaXRvcnkzMTQyNTk5MzI=",
"name": "test-checks",
"full_name": "hub4j-test-org/test-checks",
"private": true,
"owner": {
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j-test-org",
"html_url": "https://github.com/hub4j-test-org",
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/hub4j-test-org/test-checks",
"description": "Repo for testing the checks API",
"fork": false,
"url": "https://api.github.com/repos/hub4j-test-org/test-checks",
"forks_url": "https://api.github.com/repos/hub4j-test-org/test-checks/forks",
"keys_url": "https://api.github.com/repos/hub4j-test-org/test-checks/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/hub4j-test-org/test-checks/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/hub4j-test-org/test-checks/teams",
"hooks_url": "https://api.github.com/repos/hub4j-test-org/test-checks/hooks",
"issue_events_url": "https://api.github.com/repos/hub4j-test-org/test-checks/issues/events{/number}",
"events_url": "https://api.github.com/repos/hub4j-test-org/test-checks/events",
"assignees_url": "https://api.github.com/repos/hub4j-test-org/test-checks/assignees{/user}",
"branches_url": "https://api.github.com/repos/hub4j-test-org/test-checks/branches{/branch}",
"tags_url": "https://api.github.com/repos/hub4j-test-org/test-checks/tags",
"blobs_url": "https://api.github.com/repos/hub4j-test-org/test-checks/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/hub4j-test-org/test-checks/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/hub4j-test-org/test-checks/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/hub4j-test-org/test-checks/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/hub4j-test-org/test-checks/statuses/{sha}",
"languages_url": "https://api.github.com/repos/hub4j-test-org/test-checks/languages",
"stargazers_url": "https://api.github.com/repos/hub4j-test-org/test-checks/stargazers",
"contributors_url": "https://api.github.com/repos/hub4j-test-org/test-checks/contributors",
"subscribers_url": "https://api.github.com/repos/hub4j-test-org/test-checks/subscribers",
"subscription_url": "https://api.github.com/repos/hub4j-test-org/test-checks/subscription",
"commits_url": "https://api.github.com/repos/hub4j-test-org/test-checks/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/hub4j-test-org/test-checks/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/hub4j-test-org/test-checks/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/hub4j-test-org/test-checks/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/hub4j-test-org/test-checks/contents/{+path}",
"compare_url": "https://api.github.com/repos/hub4j-test-org/test-checks/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/hub4j-test-org/test-checks/merges",
"archive_url": "https://api.github.com/repos/hub4j-test-org/test-checks/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/hub4j-test-org/test-checks/downloads",
"issues_url": "https://api.github.com/repos/hub4j-test-org/test-checks/issues{/number}",
"pulls_url": "https://api.github.com/repos/hub4j-test-org/test-checks/pulls{/number}",
"milestones_url": "https://api.github.com/repos/hub4j-test-org/test-checks/milestones{/number}",
"notifications_url": "https://api.github.com/repos/hub4j-test-org/test-checks/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/hub4j-test-org/test-checks/labels{/name}",
"releases_url": "https://api.github.com/repos/hub4j-test-org/test-checks/releases{/id}",
"deployments_url": "https://api.github.com/repos/hub4j-test-org/test-checks/deployments",
"created_at": "2020-11-19T13:41:45Z",
"updated_at": "2020-11-19T13:41:50Z",
"pushed_at": "2020-11-19T13:41:47Z",
"git_url": "git://github.com/hub4j-test-org/test-checks.git",
"ssh_url": "[email protected]:hub4j-test-org/test-checks.git",
"clone_url": "https://github.com/hub4j-test-org/test-checks.git",
"svn_url": "https://github.com/hub4j-test-org/test-checks",
"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,
"disabled": false,
"open_issues_count": 0,
"license": null,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main",
"permissions": {
"admin": false,
"push": false,
"pull": false
},
"organization": {
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j-test-org",
"html_url": "https://github.com/hub4j-test-org",
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"network_count": 0,
"subscribers_count": 8
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"id": 1424883037,
"node_id": "MDg6Q2hlY2tSdW4xNDI0ODgzMDM3",
"head_sha": "89a9ae301e35e667756034fdc933b1fc94f63fc1",
"external_id": "",
"url": "https://api.github.com/repos/hub4j-test-org/test-checks/check-runs/1424883037",
"html_url": "https://github.com/hub4j-test-org/test-checks/runs/1424883037",
"details_url": "http://localhost",
"status": "in_progress",
"conclusion": null,
"started_at": "1970-01-12T13:46:39Z",
"completed_at": null,
"output": {
"title": "Some Title",
"summary": "what happened…",
"text": null,
"annotations_count": 1,
"annotations_url": "https://api.github.com/repos/hub4j-test-org/test-checks/check-runs/1424883037/annotations"
},
"name": "foo",
"check_suite": {
"id": 1529145983
},
"app": {
"id": 89368,
"slug": "ghapi-test-app-3",
"node_id": "MDM6QXBwODkzNjg=",
"owner": {
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j-test-org",
"html_url": "https://github.com/hub4j-test-org",
"followers_url": "https://api.github.com/users/hub4j-test-org/followers",
"following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j-test-org/orgs",
"repos_url": "https://api.github.com/users/hub4j-test-org/repos",
"events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j-test-org/received_events",
"type": "Organization",
"site_admin": false
},
"name": "GHApi Test app 3",
"description": "Test app for checks api testing",
"external_url": "http://localhost",
"html_url": "https://github.com/apps/ghapi-test-app-3",
"created_at": "2020-11-19T14:30:34Z",
"updated_at": "2020-11-19T14:30:34Z",
"permissions": {
"checks": "write",
"metadata": "read"
},
"events": []
},
"pull_requests": []
}
Loading