Repository: google/go-github
Pull request #3176 (2024-05-23 18:29:25)

Support `path` property in `WorkflowRun`
Fixes https://github.com/google/go-github/issues/3175

The `path` 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

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3176?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 92.93%. Comparing base [(`2b8c7fa`)](https://app.codecov.io/gh/google/go-github/commit/2b8c7fa86fcd1cb4a89a44c8e7b5a49fe4be8a45?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`4ca12d8`)](https://app.codecov.io/gh/google/go-github/pull/3176?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> Report is 64 commits behind head on master.


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #3176      +/-   ##
==========================================
- Coverage   97.72%   92.93%   -4.79%     
==========================================
  Files         153      171      +18     
  Lines       13390    11542    -1848     
==========================================
- Hits        13085    10727    -2358     
- Misses        215      724     +509     
- Partials       90       91       +1     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3176?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).


Patch:
diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go
index bc7afe9e..d55c01dc 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/github-accessors.go b/github/github-accessors.go
index 0da23493..421922d3 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 {


Test patch:
diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go
index b4b1c917..8e01aa82 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_test.go b/github/github-accessors_test.go
index 8bb86540..8753c42b 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}