in src/mcp/github-checks-server.ts [102:158]
async function extractFailedChecksInfo(
octokit: Octokit,
owner: string,
repo: string,
ref: string,
maxLength: number = 19000
): Promise<ExtractFailedChecksResult> {
try {
// Get check runs for the ref
const {data: checkRuns} = await octokit.rest.checks.listForRef({
owner,
repo,
ref,
});
// Filter only failed check runs
const failedCheckRuns = checkRuns.check_runs.filter(
(check) => check.conclusion === 'failure'
);
const failedChecksInfo: FailedCheckInfo[] = [];
// Extract information from each failed check
for (const checkRun of failedCheckRuns) {
const checkInfo = await extractCheckRunLog(
octokit,
owner,
repo,
checkRun
);
if (checkInfo) {
failedChecksInfo.push({
checkName: checkRun.name,
output: checkInfo,
});
}
}
// Combine all failed checks info
let combinedOutput = failedChecksInfo
.map((check) => `[Check name] ${check.checkName}\n[Check output]\n${check.output}`)
.join('\n\n');
if (combinedOutput.length > maxLength) {
combinedOutput = combinedOutput.substring(0, maxLength);
}
return {
failedChecks: failedChecksInfo,
combinedOutput,
};
} catch (error) {
throw error;
}
}