Improve skills validation runs (#1387)

This commit is contained in:
Jan Krivanek
2026-04-14 02:39:08 +02:00
committed by GitHub
parent b8f3822748
commit dd3bce4417

View File

@@ -44,41 +44,99 @@ jobs:
const totalChecked = skillCount + agentCount; const totalChecked = skillCount + agentCount;
const marker = '<!-- skill-validator-results -->'; const marker = '<!-- skill-validator-results -->';
const output = fs.readFileSync('sv-output.txt', 'utf8').trim(); const rawOutput = fs.existsSync('sv-output.txt')
? fs.readFileSync('sv-output.txt', 'utf8')
: '';
const output = rawOutput.replace(/\x1b\[[0-9;]*m/g, '').trim();
// Count errors, warnings, advisories from output const errorCount = (output.match(/❌/g) || []).length;
const errorCount = (output.match(/\bError\b/gi) || []).length; const warningCount = (output.match(//g) || []).length;
const warningCount = (output.match(/\bWarning\b/gi) || []).length; const advisoryCount = (output.match(//g) || []).length;
const advisoryCount = (output.match(/\bAdvisory\b/gi) || []).length;
let statusLine; let verdict = '✅ All checks passed';
if (errorCount > 0) { if (exitCode !== '0' || errorCount > 0) {
statusLine = `**${totalChecked} resource(s) checked** | ⛔ ${errorCount} error(s) | ⚠️ ${warningCount} warning(s) | ${advisoryCount} advisory(ies)`; verdict = '⛔ Findings need attention';
} else if (warningCount > 0) { } else if (warningCount > 0 || advisoryCount > 0) {
statusLine = `**${totalChecked} resource(s) checked** | ⚠️ ${warningCount} warning(s) | ${advisoryCount} advisory(ies)`; verdict = '⚠️ Warnings or advisories found';
} else {
statusLine = `**${totalChecked} resource(s) checked** | ✅ All checks passed`;
} }
const highlightedLines = output
.split('\n')
.map(line => line.trim())
.filter(Boolean)
.filter(line => !line.startsWith('###'))
.filter(line => /^[❌⚠ℹ]/.test(line));
const summaryLines = highlightedLines.length > 0
? highlightedLines.slice(0, 10)
: output
.split('\n')
.map(line => line.trim())
.filter(Boolean)
.filter(line => !line.startsWith('###'))
.slice(0, 10);
const scopeTable = [
'| Scope | Checked |',
'|---|---:|',
`| Skills | ${skillCount} |`,
`| Agents | ${agentCount} |`,
`| Total | ${totalChecked} |`,
];
const severityTable = [
'| Severity | Count |',
'|---|---:|',
`| ❌ Errors | ${errorCount} |`,
`| ⚠️ Warnings | ${warningCount} |`,
`| Advisories | ${advisoryCount} |`,
];
const findingsTable = summaryLines.length === 0
? ['_No findings were emitted by the validator._']
: [
'| Level | Finding |',
'|---|---|',
...summaryLines.map(line => {
const level = line.startsWith('❌')
? '❌'
: line.startsWith('⚠')
? '⚠️'
: line.startsWith('')
? ''
: (exitCode !== '0' ? '⛔' : '');
const text = line.replace(/^[❌⚠ℹ️\s]+/, '').replace(/\|/g, '\\|');
return `| ${level} | ${text} |`;
}),
];
const body = [ const body = [
marker, marker,
'## 🔍 Skill Validator Results', '## 🔍 Skill Validator Results',
'', '',
statusLine, `**${verdict}**`,
'',
...scopeTable,
'',
...severityTable,
'',
'### Summary',
'',
...findingsTable,
'', '',
'<details>', '<details>',
'<summary>Full output</summary>', '<summary>Full validator output</summary>',
'', '',
'```', '```text',
output, output || 'No validator output captured.',
'```', '```',
'', '',
'</details>', '</details>',
'', '',
exitCode !== '0' exitCode !== '0'
? '> **Note:** Errors were found. These are currently reported as warnings and do not block merge. Please review and address when possible.' ? '> **Note:** The validator returned a non-zero exit code. Please review the findings above before merge.'
: '', : '',
].join('\n'); ].filter(Boolean).join('\n');
// Find existing comment with our marker // Find existing comment with our marker
const { data: comments } = await github.rest.issues.listComments({ const { data: comments } = await github.rest.issues.listComments({