Skip to content

Commit 83aa9d0

Browse files
authored
Merge pull request #1078 from gsmet/expose-repository-workflows-artifacts
Expose repository for artifacts, workflows and workflow runs
2 parents 3e6a5bc + 97652c6 commit 83aa9d0

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

src/main/java/org/kohsuke/github/GHArtifact.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,60 @@ public class GHArtifact extends GHObject {
2828
private boolean expired;
2929
private String expiresAt;
3030

31+
/**
32+
* Gets the name.
33+
*
34+
* @return the name
35+
*/
3136
public String getName() {
3237
return name;
3338
}
3439

40+
/**
41+
* Gets the size of the artifact in bytes.
42+
*
43+
* @return the size
44+
*/
3545
public long getSizeInBytes() {
3646
return sizeInBytes;
3747
}
3848

49+
/**
50+
* Gets the archive download URL.
51+
*
52+
* @return the archive download URL
53+
*/
3954
public URL getArchiveDownloadUrl() {
4055
return GitHubClient.parseURL(archiveDownloadUrl);
4156
}
4257

58+
/**
59+
* If this artifact has expired.
60+
*
61+
* @return if the artifact has expired
62+
*/
4363
public boolean isExpired() {
4464
return expired;
4565
}
4666

67+
/**
68+
* Gets the date at which this artifact will expire.
69+
*
70+
* @return the date of expiration
71+
*/
4772
public Date getExpiresAt() {
4873
return GitHubClient.parseDate(expiresAt);
4974
}
5075

76+
/**
77+
* Repository to which the artifact belongs.
78+
*
79+
* @return the repository
80+
*/
81+
public GHRepository getRepository() {
82+
return owner;
83+
}
84+
5185
/**
5286
* @deprecated This object has no HTML URL.
5387
*/

src/main/java/org/kohsuke/github/GHWorkflow.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ public URL getHtmlUrl() throws IOException {
6060
return GitHubClient.parseURL(htmlUrl);
6161
}
6262

63+
/**
64+
* Repository to which the workflow belongs.
65+
*
66+
* @return the repository
67+
*/
68+
public GHRepository getRepository() {
69+
return owner;
70+
}
71+
6372
/**
6473
* The badge URL, like https://github.com/octo-org/octo-repo/workflows/CI/badge.svg
6574
*

src/main/java/org/kohsuke/github/GHWorkflowRun.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ public Conclusion getConclusion() {
213213
return Conclusion.from(conclusion);
214214
}
215215

216+
/**
217+
* Repository to which the workflow run belongs.
218+
*
219+
* @return the repository
220+
*/
221+
public GHRepository getRepository() {
222+
return owner;
223+
}
224+
216225
/**
217226
* Gets the pull requests participated in this workflow run.
218227
*

src/test/java/org/kohsuke/github/GHWorkflowRunTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public void testManualRunAndBasicInformation() throws IOException {
6262
() -> new IllegalStateException("We must have a valid workflow run starting from here"));
6363

6464
assertEquals(workflow.getId(), workflowRun.getWorkflowId());
65+
assertNotNull(workflowRun.getId());
66+
assertNotNull(workflowRun.getNodeId());
67+
assertEquals(REPO_NAME, workflowRun.getRepository().getFullName());
6568
assertTrue(workflowRun.getUrl().getPath().contains("/actions/runs/"));
6669
assertTrue(workflowRun.getHtmlUrl().getPath().contains("/actions/runs/"));
6770
assertTrue(workflowRun.getJobsUrl().getPath().endsWith("/jobs"));
@@ -379,6 +382,7 @@ private static Status getWorkflowRunStatus(GHRepository repository, long workflo
379382
private static void checkArtifactProperties(GHArtifact artifact, String artifactName) throws IOException {
380383
assertNotNull(artifact.getId());
381384
assertNotNull(artifact.getNodeId());
385+
assertEquals(REPO_NAME, artifact.getRepository().getFullName());
382386
assertThat(artifact.getName(), is(artifactName));
383387
assertThat(artifact.getArchiveDownloadUrl().getPath(), containsString("actions/artifacts"));
384388
assertNotNull(artifact.getCreatedAt());

src/test/java/org/kohsuke/github/GHWorkflowTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public void testBasicInformation() throws IOException {
4343
GHWorkflow workflow = repo.getWorkflow("test-workflow.yml");
4444

4545
assertEquals("test-workflow", workflow.getName());
46+
assertEquals(REPO_NAME, workflow.getRepository().getFullName());
4647
assertEquals(".github/workflows/test-workflow.yml", workflow.getPath());
4748
assertEquals("active", workflow.getState());
4849
assertEquals("/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859", workflow.getUrl().getPath());

0 commit comments

Comments
 (0)