Small adjustments to the API exposed to get jobs · mamh-java/java-github-api@258acf7 · GitHub
Skip to content

Commit 258acf7

Browse files
committed
Small adjustments to the API exposed to get jobs
1 parent b509076 commit 258acf7

30 files changed

Lines changed: 723 additions & 798 deletions

File tree

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

Lines changed: 13 additions & 4 deletions

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import static org.hamcrest.Matchers.containsString;
2424
import static org.hamcrest.Matchers.greaterThan;
25+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
2526
import static org.hamcrest.Matchers.hasItems;
2627
import static org.hamcrest.Matchers.is;
2728

@@ -338,9 +339,7 @@ public void testJobs() throws IOException {
338339
latestPreexistingWorkflowRunId).orElseThrow(
339340
() -> new IllegalStateException("We must have a valid workflow run starting from here"));
340341

341-
List<GHWorkflowRunJob> jobs = workflowRun.queryJobs()
342-
.latest()
343-
.list()
342+
List<GHWorkflowRunJob> jobs = workflowRun.listJobs()
344343
.toList()
345344
.stream()
346345
.sorted((j1, j2) -> j1.getName().compareTo(j2.getName()))
@@ -361,6 +360,10 @@ public void testJobs() throws IOException {
361360
// while we have a job around, test GHRepository#getWorkflowRunJob(id)
362361
GHWorkflowRunJob job1ById = repo.getWorkflowRunJob(job1.getId());
363362
checkJobProperties(workflowRun.getId(), job1ById, "job1");
363+
364+
// Also test listAllJobs() works correctly
365+
List<GHWorkflowRunJob> allJobs = workflowRun.listAllJobs().withPageSize(10).iterator().nextPage();
366+
assertThat(allJobs.size(), greaterThanOrEqualTo(2));
364367
}
365368

366369
private void await(Function<GHRepository, Boolean> condition) throws IOException {

src/test/resources/org/kohsuke/github/GHWorkflowRunTest/wiremock/testJobs/__files/repos_hub4j-test-org_ghworkflowruntest_actions_jobs__2269946728-10.json renamed to src/test/resources/org/kohsuke/github/GHWorkflowRunTest/wiremock/testJobs/__files/repos_hub4j-test-org_ghworkflowruntest_actions_jobs__2270858630-10.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
{
2-
"id": 2269946728,
3-
"run_id": 719290617,
4-
"run_url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/719290617",
5-
"node_id": "MDg6Q2hlY2tSdW4yMjY5OTQ2NzI4",
2+
"id": 2270858630,
3+
"run_id": 719643947,
4+
"run_url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/719643947",
5+
"node_id": "MDg6Q2hlY2tSdW4yMjcwODU4NjMw",
66
"head_sha": "c7bd3b8db871bbde8629275631ea645622ae89d7",
7-
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/actions/jobs/2269946728",
8-
"html_url": "https://github.com/hub4j-test-org/GHWorkflowRunTest/runs/2269946728",
7+
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/actions/jobs/2270858630",
8+
"html_url": "https://github.com/hub4j-test-org/GHWorkflowRunTest/runs/2270858630",
99
"status": "completed",
1010
"conclusion": "success",
11-
"started_at": "2021-04-05T13:14:37Z",
12-
"completed_at": "2021-04-05T13:14:38Z",
11+
"started_at": "2021-04-05T15:42:57Z",
12+
"completed_at": "2021-04-05T15:42:59Z",
1313
"name": "job1",
1414
"steps": [
1515
{
1616
"name": "Set up job",
1717
"status": "completed",
1818
"conclusion": "success",
1919
"number": 1,
20-
"started_at": "2021-04-05T15:14:37.000+02:00",
21-
"completed_at": "2021-04-05T15:14:37.000+02:00"
20+
"started_at": "2021-04-05T17:42:57.000+02:00",
21+
"completed_at": "2021-04-05T17:42:58.000+02:00"
2222
},
2323
{
2424
"name": "Run a one-line script",
2525
"status": "completed",
2626
"conclusion": "success",
2727
"number": 2,
28-
"started_at": "2021-04-05T15:14:37.000+02:00",
29-
"completed_at": "2021-04-05T15:14:38.000+02:00"
28+
"started_at": "2021-04-05T17:42:58.000+02:00",
29+
"completed_at": "2021-04-05T17:42:59.000+02:00"
3030
},
3131
{
3232
"name": "Complete job",
3333
"status": "completed",
3434
"conclusion": "success",
3535
"number": 3,
36-
"started_at": "2021-04-05T15:14:38.000+02:00",
37-
"completed_at": "2021-04-05T15:14:38.000+02:00"
36+
"started_at": "2021-04-05T17:42:59.000+02:00",
37+
"completed_at": "2021-04-05T17:42:59.000+02:00"
3838
}
3939
],
40-
"check_run_url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/check-runs/2269946728"
40+
"check_run_url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/check-runs/2270858630"
4141
}

src/test/resources/org/kohsuke/github/GHWorkflowRunTest/wiremock/testJobs/__files/repos_hub4j-test-org_ghworkflowruntest_actions_runs-4.json

Lines changed: 16 additions & 16 deletions

0 commit comments

Comments
 (0)