Skip to content

Commit dd3bce4

Browse files
authored
Improve skills validation runs (#1387)
1 parent b8f3822 commit dd3bce4

File tree

1 file changed

+78
-20
lines changed

1 file changed

+78
-20
lines changed

.github/workflows/skill-check-comment.yml

Lines changed: 78 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,41 +44,99 @@ jobs:
4444
const totalChecked = skillCount + agentCount;
4545
4646
const marker = '<!-- skill-validator-results -->';
47-
const output = fs.readFileSync('sv-output.txt', 'utf8').trim();
48-
49-
// Count errors, warnings, advisories from output
50-
const errorCount = (output.match(/\bError\b/gi) || []).length;
51-
const warningCount = (output.match(/\bWarning\b/gi) || []).length;
52-
const advisoryCount = (output.match(/\bAdvisory\b/gi) || []).length;
53-
54-
let statusLine;
55-
if (errorCount > 0) {
56-
statusLine = `**${totalChecked} resource(s) checked** | ⛔ ${errorCount} error(s) | ⚠️ ${warningCount} warning(s) | ℹ️ ${advisoryCount} advisory(ies)`;
57-
} else if (warningCount > 0) {
58-
statusLine = `**${totalChecked} resource(s) checked** | ⚠️ ${warningCount} warning(s) | ℹ️ ${advisoryCount} advisory(ies)`;
59-
} else {
60-
statusLine = `**${totalChecked} resource(s) checked** | ✅ All checks passed`;
47+
const rawOutput = fs.existsSync('sv-output.txt')
48+
? fs.readFileSync('sv-output.txt', 'utf8')
49+
: '';
50+
const output = rawOutput.replace(/\x1b\[[0-9;]*m/g, '').trim();
51+
52+
const errorCount = (output.match(/❌/g) || []).length;
53+
const warningCount = (output.match(/⚠/g) || []).length;
54+
const advisoryCount = (output.match(/ℹ/g) || []).length;
55+
56+
let verdict = '✅ All checks passed';
57+
if (exitCode !== '0' || errorCount > 0) {
58+
verdict = '⛔ Findings need attention';
59+
} else if (warningCount > 0 || advisoryCount > 0) {
60+
verdict = '⚠️ Warnings or advisories found';
6161
}
6262
63+
const highlightedLines = output
64+
.split('\n')
65+
.map(line => line.trim())
66+
.filter(Boolean)
67+
.filter(line => !line.startsWith('###'))
68+
.filter(line => /^[❌⚠ℹ]/.test(line));
69+
70+
const summaryLines = highlightedLines.length > 0
71+
? highlightedLines.slice(0, 10)
72+
: output
73+
.split('\n')
74+
.map(line => line.trim())
75+
.filter(Boolean)
76+
.filter(line => !line.startsWith('###'))
77+
.slice(0, 10);
78+
79+
const scopeTable = [
80+
'| Scope | Checked |',
81+
'|---|---:|',
82+
`| Skills | ${skillCount} |`,
83+
`| Agents | ${agentCount} |`,
84+
`| Total | ${totalChecked} |`,
85+
];
86+
87+
const severityTable = [
88+
'| Severity | Count |',
89+
'|---|---:|',
90+
`| ❌ Errors | ${errorCount} |`,
91+
`| ⚠️ Warnings | ${warningCount} |`,
92+
`| ℹ️ Advisories | ${advisoryCount} |`,
93+
];
94+
95+
const findingsTable = summaryLines.length === 0
96+
? ['_No findings were emitted by the validator._']
97+
: [
98+
'| Level | Finding |',
99+
'|---|---|',
100+
...summaryLines.map(line => {
101+
const level = line.startsWith('❌')
102+
? '❌'
103+
: line.startsWith('⚠')
104+
? '⚠️'
105+
: line.startsWith('ℹ')
106+
? 'ℹ️'
107+
: (exitCode !== '0' ? '⛔' : 'ℹ️');
108+
const text = line.replace(/^[❌⚠ℹ️\s]+/, '').replace(/\|/g, '\\|');
109+
return `| ${level} | ${text} |`;
110+
}),
111+
];
112+
63113
const body = [
64114
marker,
65115
'## 🔍 Skill Validator Results',
66116
'',
67-
statusLine,
117+
`**${verdict}**`,
118+
'',
119+
...scopeTable,
120+
'',
121+
...severityTable,
122+
'',
123+
'### Summary',
124+
'',
125+
...findingsTable,
68126
'',
69127
'<details>',
70-
'<summary>Full output</summary>',
128+
'<summary>Full validator output</summary>',
71129
'',
72-
'```',
73-
output,
130+
'```text',
131+
output || 'No validator output captured.',
74132
'```',
75133
'',
76134
'</details>',
77135
'',
78136
exitCode !== '0'
79-
? '> **Note:** Errors were found. These are currently reported as warnings and do not block merge. Please review and address when possible.'
137+
? '> **Note:** The validator returned a non-zero exit code. Please review the findings above before merge.'
80138
: '',
81-
].join('\n');
139+
].filter(Boolean).join('\n');
82140
83141
// Find existing comment with our marker
84142
const { data: comments } = await github.rest.issues.listComments({

0 commit comments

Comments
 (0)