Skip to content

Commit b26fa8f

Browse files
author
Marcelo Carlos
authored
Add missing attribute job_runs in WorkflowRunBill (#2206)
1 parent a4ce810 commit b26fa8f

File tree

4 files changed

+63
-4
lines changed

4 files changed

+63
-4
lines changed

github/actions_workflow_runs.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,15 @@ type WorkflowRunEnvironment struct {
7474

7575
// WorkflowRunBill specifies billable time for a specific environment in a workflow run.
7676
type WorkflowRunBill struct {
77-
TotalMS *int64 `json:"total_ms,omitempty"`
78-
Jobs *int `json:"jobs,omitempty"`
77+
TotalMS *int64 `json:"total_ms,omitempty"`
78+
Jobs *int `json:"jobs,omitempty"`
79+
JobRuns []*WorkflowRunJobRun `json:"job_runs,omitempty"`
80+
}
81+
82+
// WorkflowRunJobRun represents a usage of individual jobs of a specific workflow run.
83+
type WorkflowRunJobRun struct {
84+
JobID *int `json:"job_id,omitempty"`
85+
DurationMS *int64 `json:"duration_ms,omitempty"`
7986
}
8087

8188
func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {

github/actions_workflow_runs_test.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func TestActionsService_GetWorkflowRunUsageByID(t *testing.T) {
366366

367367
mux.HandleFunc("/repos/o/r/actions/runs/29679449/timing", func(w http.ResponseWriter, r *http.Request) {
368368
testMethod(t, r, "GET")
369-
fmt.Fprint(w, `{"billable":{"UBUNTU":{"total_ms":180000,"jobs":1},"MACOS":{"total_ms":240000,"jobs":4},"WINDOWS":{"total_ms":300000,"jobs":2}},"run_duration_ms":500000}`)
369+
fmt.Fprint(w, `{"billable":{"UBUNTU":{"total_ms":180000,"jobs":1,"job_runs":[{"job_id":1,"duration_ms":60000}]},"MACOS":{"total_ms":240000,"jobs":2,"job_runs":[{"job_id":2,"duration_ms":30000},{"job_id":3,"duration_ms":10000}]},"WINDOWS":{"total_ms":300000,"jobs":2}},"run_duration_ms":500000}`)
370370
})
371371

372372
ctx := context.Background()
@@ -380,10 +380,26 @@ func TestActionsService_GetWorkflowRunUsageByID(t *testing.T) {
380380
Ubuntu: &WorkflowRunBill{
381381
TotalMS: Int64(180000),
382382
Jobs: Int(1),
383+
JobRuns: []*WorkflowRunJobRun{
384+
{
385+
JobID: Int(1),
386+
DurationMS: Int64(60000),
387+
},
388+
},
383389
},
384390
MacOS: &WorkflowRunBill{
385391
TotalMS: Int64(240000),
386-
Jobs: Int(4),
392+
Jobs: Int(2),
393+
JobRuns: []*WorkflowRunJobRun{
394+
{
395+
JobID: Int(2),
396+
DurationMS: Int64(30000),
397+
},
398+
{
399+
JobID: Int(3),
400+
DurationMS: Int64(10000),
401+
},
402+
},
387403
},
388404
Windows: &WorkflowRunBill{
389405
TotalMS: Int64(300000),

github/github-accessors.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)