diff --git a/.changeset/patch-progress-indicator-workflow-runs.md b/.changeset/patch-progress-indicator-workflow-runs.md new file mode 100644 index 00000000000..9148c462534 --- /dev/null +++ b/.changeset/patch-progress-indicator-workflow-runs.md @@ -0,0 +1,5 @@ +--- +"gh-aw": patch +--- + +Add progress indicator to workflow runs fetching spinner diff --git a/pkg/cli/logs.go b/pkg/cli/logs.go index 8200bafcb36..e57620c740e 100644 --- a/pkg/cli/logs.go +++ b/pkg/cli/logs.go @@ -450,7 +450,7 @@ func DownloadWorkflowLogs(workflowName string, count int, startDate, endDate, ou } } - runs, totalFetched, err := listWorkflowRunsWithPagination(workflowName, batchSize, startDate, endDate, beforeDate, branch, beforeRunID, afterRunID, verbose) + runs, totalFetched, err := listWorkflowRunsWithPagination(workflowName, batchSize, startDate, endDate, beforeDate, branch, beforeRunID, afterRunID, len(processedRuns), count, verbose) if err != nil { return err } @@ -789,7 +789,9 @@ func downloadRunArtifactsConcurrent(runs []WorkflowRun, outputDir string, verbos // // The limit parameter specifies the batch size for the GitHub API call (how many runs to fetch in this request), // not the total number of matching runs the user wants to find. -func listWorkflowRunsWithPagination(workflowName string, limit int, startDate, endDate, beforeDate, branch string, beforeRunID, afterRunID int64, verbose bool) ([]WorkflowRun, int, error) { +// +// The processedCount and targetCount parameters are used to display progress in the spinner message. +func listWorkflowRunsWithPagination(workflowName string, limit int, startDate, endDate, beforeDate, branch string, beforeRunID, afterRunID int64, processedCount, targetCount int, verbose bool) ([]WorkflowRun, int, error) { args := []string{"run", "list", "--json", "databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle"} // Add filters @@ -819,7 +821,8 @@ func listWorkflowRunsWithPagination(workflowName string, limit int, startDate, e } // Start spinner for network operation - spinner := console.NewSpinner("Fetching workflow runs from GitHub...") + spinnerMsg := fmt.Sprintf("Fetching workflow runs from GitHub... (%d / %d)", processedCount, targetCount) + spinner := console.NewSpinner(spinnerMsg) if !verbose { spinner.Start() } diff --git a/pkg/cli/logs_test.go b/pkg/cli/logs_test.go index 55c5a4cd396..e2c2fbe52bd 100644 --- a/pkg/cli/logs_test.go +++ b/pkg/cli/logs_test.go @@ -361,7 +361,7 @@ func TestListWorkflowRunsWithPagination(t *testing.T) { // This should fail with authentication error (if not authenticated) // or succeed with empty results (if authenticated but no workflows match) - runs, _, err := listWorkflowRunsWithPagination("nonexistent-workflow", 5, "", "", "2024-01-01T00:00:00Z", "", 0, 0, false) + runs, _, err := listWorkflowRunsWithPagination("nonexistent-workflow", 5, "", "", "2024-01-01T00:00:00Z", "", 0, 0, 0, 5, false) if err != nil { // If there's an error, it should be an authentication error or workflow not found