From 621c4ba7155bee18761f308a86fa71fddf3476b4 Mon Sep 17 00:00:00 2001 From: Pavel Dvoinos Date: Fri, 25 Nov 2022 04:23:16 +0200 Subject: [PATCH] Add RunAttempt field for WorkflowJob (#2562) --- github/actions_workflow_jobs.go | 1 + github/actions_workflow_jobs_test.go | 4 +++- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index 2867e82af0..1422fd471c 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -44,6 +44,7 @@ type WorkflowJob struct { RunnerName *string `json:"runner_name,omitempty"` RunnerGroupID *int64 `json:"runner_group_id,omitempty"` RunnerGroupName *string `json:"runner_group_name,omitempty"` + RunAttempt *int64 `json:"run_attempt,omitempty"` } // Jobs represents a slice of repository action workflow job. diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 49315a03ba..204f001409 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -324,6 +324,7 @@ func TestJobs_Marshal(t *testing.T) { }, }, CheckRunURL: String("c"), + RunAttempt: Int64(2), }, }, } @@ -351,7 +352,8 @@ func TestJobs_Marshal(t *testing.T) { "started_at": ` + referenceTimeStr + `, "completed_at": ` + referenceTimeStr + ` }], - "check_run_url": "c" + "check_run_url": "c", + "run_attempt": 2 }] }` diff --git a/github/github-accessors.go b/github/github-accessors.go index 0d9db6ff89..2cc8ce0d56 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -20606,6 +20606,14 @@ func (w *WorkflowJob) GetNodeID() string { return *w.NodeID } +// GetRunAttempt returns the RunAttempt field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetRunAttempt() int64 { + if w == nil || w.RunAttempt == nil { + return 0 + } + return *w.RunAttempt +} + // GetRunID returns the RunID field if it's non-nil, zero value otherwise. func (w *WorkflowJob) GetRunID() int64 { if w == nil || w.RunID == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index bd2b95dea8..c056572596 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -24063,6 +24063,16 @@ func TestWorkflowJob_GetNodeID(tt *testing.T) { w.GetNodeID() } +func TestWorkflowJob_GetRunAttempt(tt *testing.T) { + var zeroValue int64 + w := &WorkflowJob{RunAttempt: &zeroValue} + w.GetRunAttempt() + w = &WorkflowJob{} + w.GetRunAttempt() + w = nil + w.GetRunAttempt() +} + func TestWorkflowJob_GetRunID(tt *testing.T) { var zeroValue int64 w := &WorkflowJob{RunID: &zeroValue}