Repository: google/go-github
Pull request #2238 (2021-12-23 08:56:03)

Add PreviousAttemptURL, RunAttempt, RunStartedAt field to WorkflowRun
Add `PreviousAttemptURL`, `RunAttempt`, `RunStartedAt` field to the `WorkflowRun` struct.

Fixes: #2237.

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/2238?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2238](https://codecov.io/gh/google/go-github/pull/2238?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (fb26aae) into [master](https://codecov.io/gh/google/go-github/commit/63a1994de6004a90c4e8dea108baef725c010f44?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (63a1994) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/2238/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)](https://codecov.io/gh/google/go-github/pull/2238?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)

```diff
@@           Coverage Diff           @@
##           master    #2238   +/-   ##
=======================================
  Coverage   97.80%   97.80%           
=======================================
  Files         113      113           
  Lines       10205    10205           
=======================================
  Hits         9981     9981           
  Misses        156      156           
  Partials       68       68           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/2238?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/actions\_workflow\_runs.go](https://codecov.io/gh/google/go-github/pull/2238/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2FjdGlvbnNfd29ya2Zsb3dfcnVucy5nbw==) | `100.00% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/2238?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/2238?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Last update [63a1994...fb26aae](https://codecov.io/gh/google/go-github/pull/2238?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

tohjustin: I've just signed the CLA, can one of the repository manager trigger a rescan? 😅  Thanks!

Patch:
diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go
index 2c90956c..1e1ff61a 100644
--- a/github/actions_workflow_runs.go
+++ b/github/actions_workflow_runs.go
@@ -14,33 +14,36 @@ import (
 
 // WorkflowRun represents a repository action workflow run.
 type WorkflowRun struct {
-	ID               *int64         `json:"id,omitempty"`
-	Name             *string        `json:"name,omitempty"`
-	NodeID           *string        `json:"node_id,omitempty"`
-	HeadBranch       *string        `json:"head_branch,omitempty"`
-	HeadSHA          *string        `json:"head_sha,omitempty"`
-	RunNumber        *int           `json:"run_number,omitempty"`
-	Event            *string        `json:"event,omitempty"`
-	Status           *string        `json:"status,omitempty"`
-	Conclusion       *string        `json:"conclusion,omitempty"`
-	WorkflowID       *int64         `json:"workflow_id,omitempty"`
-	CheckSuiteID     *int64         `json:"check_suite_id,omitempty"`
-	CheckSuiteNodeID *string        `json:"check_suite_node_id,omitempty"`
-	URL              *string        `json:"url,omitempty"`
-	HTMLURL          *string        `json:"html_url,omitempty"`
-	PullRequests     []*PullRequest `json:"pull_requests,omitempty"`
-	CreatedAt        *Timestamp     `json:"created_at,omitempty"`
-	UpdatedAt        *Timestamp     `json:"updated_at,omitempty"`
-	JobsURL          *string        `json:"jobs_url,omitempty"`
-	LogsURL          *string        `json:"logs_url,omitempty"`
-	CheckSuiteURL    *string        `json:"check_suite_url,omitempty"`
-	ArtifactsURL     *string        `json:"artifacts_url,omitempty"`
-	CancelURL        *string        `json:"cancel_url,omitempty"`
-	RerunURL         *string        `json:"rerun_url,omitempty"`
-	HeadCommit       *HeadCommit    `json:"head_commit,omitempty"`
-	WorkflowURL      *string        `json:"workflow_url,omitempty"`
-	Repository       *Repository    `json:"repository,omitempty"`
-	HeadRepository   *Repository    `json:"head_repository,omitempty"`
+	ID                 *int64         `json:"id,omitempty"`
+	Name               *string        `json:"name,omitempty"`
+	NodeID             *string        `json:"node_id,omitempty"`
+	HeadBranch         *string        `json:"head_branch,omitempty"`
+	HeadSHA            *string        `json:"head_sha,omitempty"`
+	RunNumber          *int           `json:"run_number,omitempty"`
+	RunAttempt         *int           `json:"run_attempt,omitempty"`
+	Event              *string        `json:"event,omitempty"`
+	Status             *string        `json:"status,omitempty"`
+	Conclusion         *string        `json:"conclusion,omitempty"`
+	WorkflowID         *int64         `json:"workflow_id,omitempty"`
+	CheckSuiteID       *int64         `json:"check_suite_id,omitempty"`
+	CheckSuiteNodeID   *string        `json:"check_suite_node_id,omitempty"`
+	URL                *string        `json:"url,omitempty"`
+	HTMLURL            *string        `json:"html_url,omitempty"`
+	PullRequests       []*PullRequest `json:"pull_requests,omitempty"`
+	CreatedAt          *Timestamp     `json:"created_at,omitempty"`
+	UpdatedAt          *Timestamp     `json:"updated_at,omitempty"`
+	RunStartedAt       *Timestamp     `json:"run_started_at,omitempty"`
+	JobsURL            *string        `json:"jobs_url,omitempty"`
+	LogsURL            *string        `json:"logs_url,omitempty"`
+	CheckSuiteURL      *string        `json:"check_suite_url,omitempty"`
+	ArtifactsURL       *string        `json:"artifacts_url,omitempty"`
+	CancelURL          *string        `json:"cancel_url,omitempty"`
+	RerunURL           *string        `json:"rerun_url,omitempty"`
+	PreviousAttemptURL *string        `json:"previous_attempt_url,omitempty"`
+	HeadCommit         *HeadCommit    `json:"head_commit,omitempty"`
+	WorkflowURL        *string        `json:"workflow_url,omitempty"`
+	Repository         *Repository    `json:"repository,omitempty"`
+	HeadRepository     *Repository    `json:"head_repository,omitempty"`
 }
 
 // WorkflowRuns represents a slice of repository action workflow run.
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 69e3499e..7ed9610d 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -18860,6 +18860,14 @@ func (w *WorkflowRun) GetNodeID() string {
 	return *w.NodeID
 }
 
+// GetPreviousAttemptURL returns the PreviousAttemptURL field if it's non-nil, zero value otherwise.
+func (w *WorkflowRun) GetPreviousAttemptURL() string {
+	if w == nil || w.PreviousAttemptURL == nil {
+		return ""
+	}
+	return *w.PreviousAttemptURL
+}
+
 // GetRepository returns the Repository field.
 func (w *WorkflowRun) GetRepository() *Repository {
 	if w == nil {
@@ -18876,6 +18884,14 @@ func (w *WorkflowRun) GetRerunURL() string {
 	return *w.RerunURL
 }
 
+// GetRunAttempt returns the RunAttempt field if it's non-nil, zero value otherwise.
+func (w *WorkflowRun) GetRunAttempt() int {
+	if w == nil || w.RunAttempt == nil {
+		return 0
+	}
+	return *w.RunAttempt
+}
+
 // GetRunNumber returns the RunNumber field if it's non-nil, zero value otherwise.
 func (w *WorkflowRun) GetRunNumber() int {
 	if w == nil || w.RunNumber == nil {
@@ -18884,6 +18900,14 @@ func (w *WorkflowRun) GetRunNumber() int {
 	return *w.RunNumber
 }
 
+// GetRunStartedAt returns the RunStartedAt field if it's non-nil, zero value otherwise.
+func (w *WorkflowRun) GetRunStartedAt() Timestamp {
+	if w == nil || w.RunStartedAt == nil {
+		return Timestamp{}
+	}
+	return *w.RunStartedAt
+}
+
 // GetStatus returns the Status field if it's non-nil, zero value otherwise.
 func (w *WorkflowRun) GetStatus() string {
 	if w == nil || w.Status == nil {


Test patch:
diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go
index d3623621..7ebdbf58 100644
--- a/github/actions_workflow_runs_test.go
+++ b/github/actions_workflow_runs_test.go
@@ -464,6 +464,7 @@ func TestWorkflowRun_Marshal(t *testing.T) {
 		HeadBranch: String("hb"),
 		HeadSHA:    String("hs"),
 		RunNumber:  Int(1),
+		RunAttempt: Int(1),
 		Event:      String("e"),
 		Status:     String("s"),
 		Conclusion: String("c"),
@@ -495,14 +496,16 @@ func TestWorkflowRun_Marshal(t *testing.T) {
 				},
 			},
 		},
-		CreatedAt:     &Timestamp{referenceTime},
-		UpdatedAt:     &Timestamp{referenceTime},
-		JobsURL:       String("j"),
-		LogsURL:       String("l"),
-		CheckSuiteURL: String("c"),
-		ArtifactsURL:  String("a"),
-		CancelURL:     String("c"),
-		RerunURL:      String("r"),
+		CreatedAt:          &Timestamp{referenceTime},
+		UpdatedAt:          &Timestamp{referenceTime},
+		RunStartedAt:       &Timestamp{referenceTime},
+		JobsURL:            String("j"),
+		LogsURL:            String("l"),
+		CheckSuiteURL:      String("c"),
+		ArtifactsURL:       String("a"),
+		CancelURL:          String("c"),
+		RerunURL:           String("r"),
+		PreviousAttemptURL: String("p"),
 		HeadCommit: &HeadCommit{
 			Message: String("m"),
 			Author: &CommitAuthor{
@@ -542,6 +545,7 @@ func TestWorkflowRun_Marshal(t *testing.T) {
 		"head_branch": "hb",
 		"head_sha": "hs",
 		"run_number": 1,
+		"run_attempt": 1,
 		"event": "e",
 		"status": "s",
 		"conclusion": "c",
@@ -575,12 +579,14 @@ func TestWorkflowRun_Marshal(t *testing.T) {
 		],
 		"created_at": ` + referenceTimeStr + `,
 		"updated_at": ` + referenceTimeStr + `,
+		"run_started_at": ` + referenceTimeStr + `,
 		"jobs_url": "j",
 		"logs_url": "l",
 		"check_suite_url": "c",
 		"artifacts_url": "a",
 		"cancel_url": "c",
 		"rerun_url": "r",
+		"previous_attempt_url": "p",
 		"head_commit": {
 			"message": "m",
 			"author": {
@@ -629,6 +635,7 @@ func TestWorkflowRuns_Marshal(t *testing.T) {
 				HeadBranch: String("hb"),
 				HeadSHA:    String("hs"),
 				RunNumber:  Int(1),
+				RunAttempt: Int(1),
 				Event:      String("e"),
 				Status:     String("s"),
 				Conclusion: String("c"),
@@ -660,14 +667,16 @@ func TestWorkflowRuns_Marshal(t *testing.T) {
 						},
 					},
 				},
-				CreatedAt:     &Timestamp{referenceTime},
-				UpdatedAt:     &Timestamp{referenceTime},
-				JobsURL:       String("j"),
-				LogsURL:       String("l"),
-				CheckSuiteURL: String("c"),
-				ArtifactsURL:  String("a"),
-				CancelURL:     String("c"),
-				RerunURL:      String("r"),
+				CreatedAt:          &Timestamp{referenceTime},
+				UpdatedAt:          &Timestamp{referenceTime},
+				RunStartedAt:       &Timestamp{referenceTime},
+				JobsURL:            String("j"),
+				LogsURL:            String("l"),
+				CheckSuiteURL:      String("c"),
+				ArtifactsURL:       String("a"),
+				CancelURL:          String("c"),
+				RerunURL:           String("r"),
+				PreviousAttemptURL: String("p"),
 				HeadCommit: &HeadCommit{
 					Message: String("m"),
 					Author: &CommitAuthor{
@@ -712,6 +721,7 @@ func TestWorkflowRuns_Marshal(t *testing.T) {
 				"head_branch": "hb",
 				"head_sha": "hs",
 				"run_number": 1,
+				"run_attempt": 1,
 				"event": "e",
 				"status": "s",
 				"conclusion": "c",
@@ -745,12 +755,14 @@ func TestWorkflowRuns_Marshal(t *testing.T) {
 				],
 				"created_at": ` + referenceTimeStr + `,
 				"updated_at": ` + referenceTimeStr + `,
+				"run_started_at": ` + referenceTimeStr + `,
 				"jobs_url": "j",
 				"logs_url": "l",
 				"check_suite_url": "c",
 				"artifacts_url": "a",
 				"cancel_url": "c",
 				"rerun_url": "r",
+				"previous_attempt_url": "p",
 				"head_commit": {
 					"message": "m",
 					"author": {
diff --git a/github/event_types_test.go b/github/event_types_test.go
index bb5dd40d..a434a009 100644
--- a/github/event_types_test.go
+++ b/github/event_types_test.go
@@ -8359,6 +8359,7 @@ func TestWorkflowRunEvent_Marshal(t *testing.T) {
 			HeadBranch: String("hb"),
 			HeadSHA:    String("hs"),
 			RunNumber:  Int(1),
+			RunAttempt: Int(1),
 			Event:      String("e"),
 			Status:     String("s"),
 			Conclusion: String("c"),
@@ -8390,14 +8391,16 @@ func TestWorkflowRunEvent_Marshal(t *testing.T) {
 					},
 				},
 			},
-			CreatedAt:     &Timestamp{referenceTime},
-			UpdatedAt:     &Timestamp{referenceTime},
-			JobsURL:       String("j"),
-			LogsURL:       String("l"),
-			CheckSuiteURL: String("c"),
-			ArtifactsURL:  String("a"),
-			CancelURL:     String("c"),
-			RerunURL:      String("r"),
+			CreatedAt:          &Timestamp{referenceTime},
+			UpdatedAt:          &Timestamp{referenceTime},
+			RunStartedAt:       &Timestamp{referenceTime},
+			JobsURL:            String("j"),
+			LogsURL:            String("l"),
+			CheckSuiteURL:      String("c"),
+			ArtifactsURL:       String("a"),
+			CancelURL:          String("c"),
+			RerunURL:           String("r"),
+			PreviousAttemptURL: String("p"),
 			HeadCommit: &HeadCommit{
 				Message: String("m"),
 				Author: &CommitAuthor{
@@ -8488,6 +8491,7 @@ func TestWorkflowRunEvent_Marshal(t *testing.T) {
 			"head_branch": "hb",
 			"head_sha": "hs",
 			"run_number": 1,
+			"run_attempt": 1,
 			"event": "e",
 			"status": "s",
 			"conclusion": "c",
@@ -8521,12 +8525,14 @@ func TestWorkflowRunEvent_Marshal(t *testing.T) {
 			],
 			"created_at": ` + referenceTimeStr + `,
 			"updated_at": ` + referenceTimeStr + `,
+			"run_started_at": ` + referenceTimeStr + `,
 			"jobs_url": "j",
 			"logs_url": "l",
 			"check_suite_url": "c",
 			"artifacts_url": "a",
 			"cancel_url": "c",
 			"rerun_url": "r",
+			"previous_attempt_url": "p",
 			"head_commit": {
 				"message": "m",
 				"author": {
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 27e0ab14..2dfed628 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -22079,6 +22079,16 @@ func TestWorkflowRun_GetNodeID(tt *testing.T) {
 	w.GetNodeID()
 }
 
+func TestWorkflowRun_GetPreviousAttemptURL(tt *testing.T) {
+	var zeroValue string
+	w := &WorkflowRun{PreviousAttemptURL: &zeroValue}
+	w.GetPreviousAttemptURL()
+	w = &WorkflowRun{}
+	w.GetPreviousAttemptURL()
+	w = nil
+	w.GetPreviousAttemptURL()
+}
+
 func TestWorkflowRun_GetRepository(tt *testing.T) {
 	w := &WorkflowRun{}
 	w.GetRepository()
@@ -22096,6 +22106,16 @@ func TestWorkflowRun_GetRerunURL(tt *testing.T) {
 	w.GetRerunURL()
 }
 
+func TestWorkflowRun_GetRunAttempt(tt *testing.T) {
+	var zeroValue int
+	w := &WorkflowRun{RunAttempt: &zeroValue}
+	w.GetRunAttempt()
+	w = &WorkflowRun{}
+	w.GetRunAttempt()
+	w = nil
+	w.GetRunAttempt()
+}
+
 func TestWorkflowRun_GetRunNumber(tt *testing.T) {
 	var zeroValue int
 	w := &WorkflowRun{RunNumber: &zeroValue}
@@ -22106,6 +22126,16 @@ func TestWorkflowRun_GetRunNumber(tt *testing.T) {
 	w.GetRunNumber()
 }
 
+func TestWorkflowRun_GetRunStartedAt(tt *testing.T) {
+	var zeroValue Timestamp
+	w := &WorkflowRun{RunStartedAt: &zeroValue}
+	w.GetRunStartedAt()
+	w = &WorkflowRun{}
+	w.GetRunStartedAt()
+	w = nil
+	w.GetRunStartedAt()
+}
+
 func TestWorkflowRun_GetStatus(tt *testing.T) {
 	var zeroValue string
 	w := &WorkflowRun{Status: &zeroValue}