From 4ca12d8b84b2d1f8b1a1da34125227d7dc347c90 Mon Sep 17 00:00:00 2001 From: Richard Macklin Date: Thu, 23 May 2024 11:24:39 -0700 Subject: [PATCH] Support path property in WorkflowRun This property is included in the response from these GitHub API endpoints: - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#get-a-workflow-run - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#get-a-workflow-run-attempt --- github/actions_workflow_runs.go | 1 + github/actions_workflow_runs_test.go | 2 ++ github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ 4 files changed, 21 insertions(+) diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go index bc7afe9e944..d55c01dcd74 100644 --- a/github/actions_workflow_runs.go +++ b/github/actions_workflow_runs.go @@ -19,6 +19,7 @@ type WorkflowRun struct { NodeID *string `json:"node_id,omitempty"` HeadBranch *string `json:"head_branch,omitempty"` HeadSHA *string `json:"head_sha,omitempty"` + Path *string `json:"path,omitempty"` RunNumber *int `json:"run_number,omitempty"` RunAttempt *int `json:"run_attempt,omitempty"` Event *string `json:"event,omitempty"` diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index b4b1c9177f6..8e01aa82297 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -648,6 +648,7 @@ func TestWorkflowRun_Marshal(t *testing.T) { NodeID: String("nid"), HeadBranch: String("hb"), HeadSHA: String("hs"), + Path: String("p"), RunNumber: Int(1), RunAttempt: Int(1), Event: String("e"), @@ -776,6 +777,7 @@ func TestWorkflowRun_Marshal(t *testing.T) { "node_id": "nid", "head_branch": "hb", "head_sha": "hs", + "path": "p", "run_number": 1, "run_attempt": 1, "event": "e", diff --git a/github/github-accessors.go b/github/github-accessors.go index 0da23493ec2..421922d33db 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -25326,6 +25326,14 @@ func (w *WorkflowRun) GetNodeID() string { return *w.NodeID } +// GetPath returns the Path field if it's non-nil, zero value otherwise. +func (w *WorkflowRun) GetPath() string { + if w == nil || w.Path == nil { + return "" + } + return *w.Path +} + // GetPreviousAttemptURL returns the PreviousAttemptURL field if it's non-nil, zero value otherwise. func (w *WorkflowRun) GetPreviousAttemptURL() string { if w == nil || w.PreviousAttemptURL == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 8bb86540d9b..8753c42b79e 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -29477,6 +29477,16 @@ func TestWorkflowRun_GetNodeID(tt *testing.T) { w.GetNodeID() } +func TestWorkflowRun_GetPath(tt *testing.T) { + var zeroValue string + w := &WorkflowRun{Path: &zeroValue} + w.GetPath() + w = &WorkflowRun{} + w.GetPath() + w = nil + w.GetPath() +} + func TestWorkflowRun_GetPreviousAttemptURL(tt *testing.T) { var zeroValue string w := &WorkflowRun{PreviousAttemptURL: &zeroValue}