Skip to content

Commit aff7201

Browse files
authored
ci: fix check failure jobs (#18225)
1 parent 252dee3 commit aff7201

File tree

1 file changed

+69
-19
lines changed

1 file changed

+69
-19
lines changed

.github/scripts/retry_failed_jobs.js

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ async function getWorkflowInfo(github, context, core, runID) {
162162
core.info(` Job ${job.name} (ID: ${job.id}) status: ${job.status}, conclusion: ${job.conclusion}`);
163163
}
164164

165-
const failedJobs = jobs.jobs.filter(job => job.conclusion === 'failure' || job.conclusion === 'cancelled');
165+
const failedJobs = jobs.jobs.filter(job => (job.conclusion === 'failure' || job.conclusion === 'cancelled') && job.name !== 'ready');
166166

167167
if (failedJobs.length === 0) {
168168
core.info('No failed jobs found to retry');
@@ -268,46 +268,96 @@ async function addCommentToPR(github, context, core, runID, runURL, failedJobs,
268268
return;
269269
}
270270

271-
let comment = `🤖 **Smart Auto-retry Analysis (Annotations-based)**
272-
273-
The workflow run [${runID}](${runURL}) failed and has been analyzed for retryable errors using job annotations.
271+
let comment = `## 🤖 Smart Auto-retry Analysis
274272
275-
**Analysis Results:**
276-
- Total failed/cancelled jobs: ${failedJobs.length}
277-
- Jobs with retryable errors: ${retryableJobsCount}
278-
- Jobs with code/test issues: ${failedJobs.length - retryableJobsCount}`;
273+
> **Workflow Run:** [\`${runID}\`](${runURL})
274+
275+
The workflow run has been analyzed for retryable errors using job annotations.
276+
277+
---
278+
279+
### 📊 Analysis Summary
280+
281+
| Metric | Count |
282+
|--------|-------|
283+
| **Total Failed/Cancelled Jobs** | \`${failedJobs.length}\` |
284+
| **Jobs with Retryable Errors** | \`${retryableJobsCount}\` |
285+
| **Jobs with Code/Test Issues** | \`${failedJobs.length - retryableJobsCount}\` |`;
279286

280287
if (priorityCancelled) {
281288
comment += `
282-
- ⛔️ **Retry cancelled** due to higher priority request`;
289+
290+
### ⛔️ Retry Status: **CANCELLED**
291+
292+
> **Reason:** Higher priority request detected - retry has been cancelled to avoid resource conflicts.`;
283293
} else if (retryableJobsCount > 0) {
284294
comment += `
285-
- ✅ **${retryableJobsCount} job(s) have been automatically retried** due to infrastructure issues detected in annotations (runner communication, network timeouts, resource exhaustion, etc.)
286295
287-
You can monitor the retry progress in the [Actions tab](${runURL}).`;
296+
### ✅ Retry Status: **AUTOMATIC RETRY INITIATED**
297+
298+
> **${retryableJobsCount} job(s)** have been automatically retried due to infrastructure issues detected in annotations:
299+
> - Runner communication failures
300+
> - Network timeouts
301+
> - Resource exhaustion
302+
> - Other transient infrastructure problems
303+
304+
**📈 Monitor Progress:** [View in Actions](${runURL})`;
288305
} else {
289306
comment += `
290-
- ❌ **No jobs were retried** because all failures appear to be code or test related issues that require manual fixes.`;
307+
308+
### ❌ Retry Status: **NO RETRY NEEDED**
309+
310+
> All failures appear to be **code or test related issues** that require manual fixes rather than automatic retries.`;
291311
}
292312

293313
comment += `
294314
295-
**Job Analysis (based on annotations):**
315+
---
316+
317+
### 🔍 Detailed Job Analysis
318+
296319
${analyzedJobs.map(job => {
297320
if (job.reason.includes('Analysis failed')) {
298-
return `- ${job.name}: ❓ ${job.reason}`;
321+
return `#### ❓ **${job.name}**
322+
> **Status:** Analysis failed
323+
> **Reason:** ${job.reason}`;
299324
}
300325
if (job.reason.includes('Cancelled by higher priority')) {
301-
return `- ${job.name}: ⛔️ ${job.reason}`;
326+
return `#### ⛔️ **${job.name}**
327+
> **Status:** Cancelled by higher priority request
328+
> **Reason:** ${job.reason}`;
302329
}
303330
if (job.reason.includes('No annotations found')) {
304-
return `- ${job.name}: ❓ ${job.reason}`;
331+
return `#### ❓ **${job.name}**
332+
> **Status:** No annotations available
333+
> **Reason:** ${job.reason}`;
334+
}
335+
if (job.retryable) {
336+
return `#### 🔄 **${job.name}**
337+
> **Status:** ✅ **Retryable** (Infrastructure Issue)
338+
> **Reason:** ${job.reason}
339+
> **Annotations:** ${job.annotationCount} found`;
340+
} else {
341+
return `#### ❌ **${job.name}**
342+
> **Status:** Not retryable (Code/Test Issue)
343+
> **Reason:** ${job.reason}
344+
> **Annotations:** ${job.annotationCount} found`;
305345
}
306-
return `- ${job.name}: ${job.retryable ? '🔄 Retryable (infrastructure)' : '❌ Not retryable (code/test)'} - ${job.reason} (${job.annotationCount} annotations)`;
307-
}).join('\n')}
346+
}).join('\n\n')}
308347
309348
---
310-
*This is an automated analysis and retry triggered by the smart retry workflow using job annotations.*`;
349+
350+
<details>
351+
<summary>🤖 About This Analysis</summary>
352+
353+
This is an **automated analysis and retry** triggered by the smart retry workflow using job annotations. The system analyzes failure patterns to distinguish between:
354+
355+
- **🔄 Infrastructure Issues:** Runner failures, network timeouts, resource exhaustion
356+
- **❌ Code/Test Issues:** Compilation errors, test failures, logic problems
357+
358+
Only infrastructure issues are automatically retried to avoid wasting resources on code problems that need manual fixes.
359+
360+
</details>`;
311361

312362
await github.rest.issues.createComment({
313363
owner: context.repo.owner,

0 commit comments

Comments
 (0)