mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-10 08:21:21 +00:00
Rename GHWorkflowRunJob to GHWorkflowJob
This commit is contained in:
@@ -3061,10 +3061,10 @@ public class GHRepository extends GHObject {
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHWorkflowRunJob getWorkflowRunJob(long id) throws IOException {
|
||||
public GHWorkflowJob getWorkflowJob(long id) throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(getApiTailUrl("/actions/jobs/"), String.valueOf(id))
|
||||
.fetch(GHWorkflowRunJob.class)
|
||||
.fetch(GHWorkflowJob.class)
|
||||
.wrapUp(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import static java.util.Objects.requireNonNull;
|
||||
*
|
||||
* @author Guillaume Smet
|
||||
*/
|
||||
public class GHWorkflowRunJob extends GHObject {
|
||||
public class GHWorkflowJob extends GHObject {
|
||||
|
||||
// Not provided by the API.
|
||||
@JsonIgnore
|
||||
@@ -171,12 +171,12 @@ public class GHWorkflowRunJob extends GHObject {
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/actions/jobs/" + getId();
|
||||
}
|
||||
|
||||
GHWorkflowRunJob wrapUp(GHRepository owner) {
|
||||
GHWorkflowJob wrapUp(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
return wrapUp(owner.root);
|
||||
}
|
||||
|
||||
GHWorkflowRunJob wrapUp(GitHub root) {
|
||||
GHWorkflowJob wrapUp(GitHub root) {
|
||||
this.root = root;
|
||||
if (owner != null) {
|
||||
owner.wrap(root);
|
||||
@@ -7,10 +7,10 @@ import java.net.MalformedURLException;
|
||||
*
|
||||
* @author Guillaume Smet
|
||||
*/
|
||||
public class GHWorkflowRunJobQueryBuilder extends GHQueryBuilder<GHWorkflowRunJob> {
|
||||
public class GHWorkflowJobQueryBuilder extends GHQueryBuilder<GHWorkflowJob> {
|
||||
private final GHRepository repo;
|
||||
|
||||
GHWorkflowRunJobQueryBuilder(GHWorkflowRun workflowRun) {
|
||||
GHWorkflowJobQueryBuilder(GHWorkflowRun workflowRun) {
|
||||
super(workflowRun.getRepository().root);
|
||||
this.repo = workflowRun.getRepository();
|
||||
req.withUrlPath(repo.getApiTailUrl("actions/runs"), String.valueOf(workflowRun.getId()), "jobs");
|
||||
@@ -21,7 +21,7 @@ public class GHWorkflowRunJobQueryBuilder extends GHQueryBuilder<GHWorkflowRunJo
|
||||
*
|
||||
* @return the workflow run job query builder
|
||||
*/
|
||||
public GHWorkflowRunJobQueryBuilder latest() {
|
||||
public GHWorkflowJobQueryBuilder latest() {
|
||||
req.with("filter", "latest");
|
||||
return this;
|
||||
}
|
||||
@@ -31,15 +31,15 @@ public class GHWorkflowRunJobQueryBuilder extends GHQueryBuilder<GHWorkflowRunJo
|
||||
*
|
||||
* @return the workflow run job run query builder
|
||||
*/
|
||||
public GHWorkflowRunJobQueryBuilder all() {
|
||||
public GHWorkflowJobQueryBuilder all() {
|
||||
req.with("filter", "all");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PagedIterable<GHWorkflowRunJob> list() {
|
||||
public PagedIterable<GHWorkflowJob> list() {
|
||||
try {
|
||||
return new GHWorkflowRunJobsIterable(repo, req.build());
|
||||
return new GHWorkflowJobsIterable(repo, req.build());
|
||||
} catch (MalformedURLException e) {
|
||||
throw new GHException(e.getMessage(), e);
|
||||
}
|
||||
@@ -7,37 +7,37 @@ import javax.annotation.Nonnull;
|
||||
/**
|
||||
* Iterable for workflow run jobs listing.
|
||||
*/
|
||||
class GHWorkflowRunJobsIterable extends PagedIterable<GHWorkflowRunJob> {
|
||||
class GHWorkflowJobsIterable extends PagedIterable<GHWorkflowJob> {
|
||||
private final GHRepository repo;
|
||||
private final GitHubRequest request;
|
||||
|
||||
private GHWorkflowRunJobsPage result;
|
||||
private GHWorkflowJobsPage result;
|
||||
|
||||
public GHWorkflowRunJobsIterable(GHRepository repo, GitHubRequest request) {
|
||||
public GHWorkflowJobsIterable(GHRepository repo, GitHubRequest request) {
|
||||
this.repo = repo;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PagedIterator<GHWorkflowRunJob> _iterator(int pageSize) {
|
||||
public PagedIterator<GHWorkflowJob> _iterator(int pageSize) {
|
||||
return new PagedIterator<>(
|
||||
adapt(GitHubPageIterator.create(repo.root.getClient(), GHWorkflowRunJobsPage.class, request, pageSize)),
|
||||
adapt(GitHubPageIterator.create(repo.root.getClient(), GHWorkflowJobsPage.class, request, pageSize)),
|
||||
null);
|
||||
}
|
||||
|
||||
protected Iterator<GHWorkflowRunJob[]> adapt(final Iterator<GHWorkflowRunJobsPage> base) {
|
||||
return new Iterator<GHWorkflowRunJob[]>() {
|
||||
protected Iterator<GHWorkflowJob[]> adapt(final Iterator<GHWorkflowJobsPage> base) {
|
||||
return new Iterator<GHWorkflowJob[]>() {
|
||||
public boolean hasNext() {
|
||||
return base.hasNext();
|
||||
}
|
||||
|
||||
public GHWorkflowRunJob[] next() {
|
||||
GHWorkflowRunJobsPage v = base.next();
|
||||
public GHWorkflowJob[] next() {
|
||||
GHWorkflowJobsPage v = base.next();
|
||||
if (result == null) {
|
||||
result = v;
|
||||
}
|
||||
return v.getWorkflowRunJobs(repo);
|
||||
return v.getWorkflowJobs(repo);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -3,16 +3,16 @@ package org.kohsuke.github;
|
||||
/**
|
||||
* Represents the one page of jobs result when listing jobs from a workflow run.
|
||||
*/
|
||||
class GHWorkflowRunJobsPage {
|
||||
class GHWorkflowJobsPage {
|
||||
private int total_count;
|
||||
private GHWorkflowRunJob[] jobs;
|
||||
private GHWorkflowJob[] jobs;
|
||||
|
||||
public int getTotalCount() {
|
||||
return total_count;
|
||||
}
|
||||
|
||||
GHWorkflowRunJob[] getWorkflowRunJobs(GHRepository repo) {
|
||||
for (GHWorkflowRunJob job : jobs) {
|
||||
GHWorkflowJob[] getWorkflowJobs(GHRepository repo) {
|
||||
for (GHWorkflowJob job : jobs) {
|
||||
job.wrapUp(repo);
|
||||
}
|
||||
return jobs;
|
||||
@@ -318,8 +318,8 @@ public class GHWorkflowRun extends GHObject {
|
||||
*
|
||||
* @return list of jobs from the last execution
|
||||
*/
|
||||
public PagedIterable<GHWorkflowRunJob> listJobs() {
|
||||
return new GHWorkflowRunJobQueryBuilder(this).latest().list();
|
||||
public PagedIterable<GHWorkflowJob> listJobs() {
|
||||
return new GHWorkflowJobQueryBuilder(this).latest().list();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,8 +327,8 @@ public class GHWorkflowRun extends GHObject {
|
||||
*
|
||||
* @return list of jobs from all the executions
|
||||
*/
|
||||
public PagedIterable<GHWorkflowRunJob> listAllJobs() {
|
||||
return new GHWorkflowRunJobQueryBuilder(this).all().list();
|
||||
public PagedIterable<GHWorkflowJob> listAllJobs() {
|
||||
return new GHWorkflowJobQueryBuilder(this).all().list();
|
||||
}
|
||||
|
||||
private String getApiRoute() {
|
||||
|
||||
@@ -4,9 +4,9 @@ import org.awaitility.Awaitility;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.kohsuke.github.GHWorkflowJob.Step;
|
||||
import org.kohsuke.github.GHWorkflowRun.Conclusion;
|
||||
import org.kohsuke.github.GHWorkflowRun.Status;
|
||||
import org.kohsuke.github.GHWorkflowRunJob.Step;
|
||||
import org.kohsuke.github.function.InputStreamFunction;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -339,7 +339,7 @@ public class GHWorkflowRunTest extends AbstractGitHubWireMockTest {
|
||||
latestPreexistingWorkflowRunId).orElseThrow(
|
||||
() -> new IllegalStateException("We must have a valid workflow run starting from here"));
|
||||
|
||||
List<GHWorkflowRunJob> jobs = workflowRun.listJobs()
|
||||
List<GHWorkflowJob> jobs = workflowRun.listJobs()
|
||||
.toList()
|
||||
.stream()
|
||||
.sorted((j1, j2) -> j1.getName().compareTo(j2.getName()))
|
||||
@@ -347,22 +347,22 @@ public class GHWorkflowRunTest extends AbstractGitHubWireMockTest {
|
||||
|
||||
assertThat(jobs.size(), is(2));
|
||||
|
||||
GHWorkflowRunJob job1 = jobs.get(0);
|
||||
GHWorkflowJob job1 = jobs.get(0);
|
||||
checkJobProperties(workflowRun.getId(), job1, "job1");
|
||||
String fullLogContent = job1.downloadLogs(getLogTextInputStreamFunction());
|
||||
assertThat(fullLogContent, containsString("Hello from job1!"));
|
||||
|
||||
GHWorkflowRunJob job2 = jobs.get(1);
|
||||
GHWorkflowJob job2 = jobs.get(1);
|
||||
checkJobProperties(workflowRun.getId(), job2, "job2");
|
||||
fullLogContent = job2.downloadLogs(getLogTextInputStreamFunction());
|
||||
assertThat(fullLogContent, containsString("Hello from job2!"));
|
||||
|
||||
// while we have a job around, test GHRepository#getWorkflowRunJob(id)
|
||||
GHWorkflowRunJob job1ById = repo.getWorkflowRunJob(job1.getId());
|
||||
// while we have a job around, test GHRepository#getWorkflowJob(id)
|
||||
GHWorkflowJob job1ById = repo.getWorkflowJob(job1.getId());
|
||||
checkJobProperties(workflowRun.getId(), job1ById, "job1");
|
||||
|
||||
// Also test listAllJobs() works correctly
|
||||
List<GHWorkflowRunJob> allJobs = workflowRun.listAllJobs().withPageSize(10).iterator().nextPage();
|
||||
List<GHWorkflowJob> allJobs = workflowRun.listAllJobs().withPageSize(10).iterator().nextPage();
|
||||
assertThat(allJobs.size(), greaterThanOrEqualTo(2));
|
||||
}
|
||||
|
||||
@@ -468,8 +468,7 @@ public class GHWorkflowRunTest extends AbstractGitHubWireMockTest {
|
||||
assertFalse(artifact.isExpired());
|
||||
}
|
||||
|
||||
private static void checkJobProperties(long workflowRunId, GHWorkflowRunJob job, String jobName)
|
||||
throws IOException {
|
||||
private static void checkJobProperties(long workflowRunId, GHWorkflowJob job, String jobName) throws IOException {
|
||||
assertNotNull(job.getId());
|
||||
assertNotNull(job.getNodeId());
|
||||
assertEquals(REPO_NAME, job.getRepository().getFullName());
|
||||
|
||||
Reference in New Issue
Block a user