From 105bafd2ec2d4f73f9b48bd7d0a00a8ddaad16b6 Mon Sep 17 00:00:00 2001 From: cawfeecake <48775802+cawfeecake@users.noreply.github.com> Date: Wed, 22 May 2024 05:39:13 -0700 Subject: [PATCH] fix: rename the `Attempts` field to `Attempt`; expose in `gh run view` and `gh run ls` (#8905) Co-authored-by: William Martin --- pkg/cmd/run/shared/shared.go | 3 ++- pkg/cmd/run/shared/shared_test.go | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/run/shared/shared.go b/pkg/cmd/run/shared/shared.go index 6c76714fd..a5bccee85 100644 --- a/pkg/cmd/run/shared/shared.go +++ b/pkg/cmd/run/shared/shared.go @@ -72,6 +72,7 @@ var RunFields = []string{ "createdAt", "updatedAt", "startedAt", + "attempt", "status", "conclusion", "event", @@ -97,7 +98,7 @@ type Run struct { workflowName string // cache column WorkflowID int64 `json:"workflow_id"` Number int64 `json:"run_number"` - Attempts uint64 `json:"run_attempt"` + Attempt uint64 `json:"run_attempt"` HeadBranch string `json:"head_branch"` JobsURL string `json:"jobs_url"` HeadCommit Commit `json:"head_commit"` diff --git a/pkg/cmd/run/shared/shared_test.go b/pkg/cmd/run/shared/shared_test.go index 815a6556c..15663cd0a 100644 --- a/pkg/cmd/run/shared/shared_test.go +++ b/pkg/cmd/run/shared/shared_test.go @@ -189,6 +189,15 @@ func TestRunExportData(t *testing.T) { }, output: `{"jobs":[{"completedAt":"2022-07-20T11:21:16Z","conclusion":"success","databaseId":123456,"name":"macos","startedAt":"2022-07-20T11:20:13Z","status":"completed","steps":[{"conclusion":"success","name":"Checkout","number":1,"status":"completed"}],"url":"https://example.com/OWNER/REPO/actions/runs/123456"},{"completedAt":"2022-07-20T11:23:16Z","conclusion":"error","databaseId":234567,"name":"windows","startedAt":"2022-07-20T11:20:55Z","status":"completed","steps":[{"conclusion":"error","name":"Checkout","number":2,"status":"completed"}],"url":"https://example.com/OWNER/REPO/actions/runs/234567"}]}`, }, + { + name: "exports workflow run with attempt count", + fields: []string{"attempt"}, + run: Run{ + Attempt: 1, + Jobs: []Job{}, + }, + output: `{"attempt":1}`, + }, } for _, tt := range tests {