@@ -96,7 +96,7 @@ var GenerateReportCmd = &cobra.Command{
9696 var artifactLink string
9797 if hasFailedTests && githubRepo != "" && githubRunID != 0 && artifactName != "" {
9898 // Fetch artifact link from GitHub API
99- artifactLink , err = fetchArtifactLink (githubToken , githubRepo , githubRunID , artifactName )
99+ artifactLink , err = fetchArtifactLinkWithRetry (githubToken , githubRepo , githubRunID , artifactName , 5 , 5 * time . Second )
100100 if err != nil {
101101 return fmt .Errorf ("error fetching artifact link: %w" , err )
102102 }
@@ -216,7 +216,7 @@ func fetchArtifactLink(githubToken, githubRepo string, githubRunID int64, artifa
216216 owner , repo := repoParts [0 ], repoParts [1 ]
217217
218218 // List artifacts for the workflow run
219- opts := & github.ListOptions {Page : 5 , PerPage : 100 }
219+ opts := & github.ListOptions {PerPage : 500 }
220220 artifacts , _ , err := client .Actions .ListWorkflowRunArtifacts (ctx , owner , repo , githubRunID , opts )
221221 if err != nil {
222222 return "" , fmt .Errorf ("error listing artifacts: %w" , err )
@@ -235,6 +235,33 @@ func fetchArtifactLink(githubToken, githubRepo string, githubRunID int64, artifa
235235 return "" , fmt .Errorf ("artifact '%s' not found in the workflow run" , artifactName )
236236}
237237
238+ func fetchArtifactLinkWithRetry (
239+ githubToken , githubRepo string ,
240+ githubRunID int64 , artifactName string ,
241+ maxRetries int , delay time.Duration ,
242+ ) (string , error ) {
243+ var lastErr error
244+ for attempt := 1 ; attempt <= maxRetries ; attempt ++ {
245+ link , err := fetchArtifactLink (githubToken , githubRepo , githubRunID , artifactName )
246+ if err == nil {
247+ // Found the artifact link successfully
248+ return link , nil
249+ }
250+
251+ // If this was our last attempt, return the error
252+ lastErr = err
253+ if attempt == maxRetries {
254+ break
255+ }
256+
257+ // Otherwise wait and retry
258+ log .Printf ("[Attempt %d/%d] Artifact not yet available. Retrying in %s..." , attempt , maxRetries , delay )
259+ time .Sleep (delay )
260+ }
261+
262+ return "" , fmt .Errorf ("failed to fetch artifact link after %d retries: %w" , maxRetries , lastErr )
263+ }
264+
238265func generateGitHubSummaryMarkdown (report * reports.TestReport , outputPath , artifactLink , artifactName string ) error {
239266 fs := reports.OSFileSystem {}
240267 mdFileName := outputPath + "-summary.md"
0 commit comments