diagnose-ci-failures

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

diagnose-ci-failures

diagnose-ci-failures

Programmatically diagnose CI failures for a PR and generate a plan to fix them.
以编程方式诊断PR的CI失败问题并生成修复方案。

Overview

概述

This skill provides a deterministic workflow to check CI status for a PR, extract failure logs, analyze errors, and create a plan (not code changes) to resolve issues. The output is always a plan document that can be reviewed before execution.
此技能提供一个确定性工作流,用于检查PR的CI状态、提取失败日志、分析错误并创建修复方案(不包含代码变更)。输出始终是一份可在执行前审核的方案文档。

Workflow

工作流

1. Verify PR exists for current branch

1. 验证当前分支是否存在PR

Get the current branch and check if a PR exists:
bash
undefined
获取当前分支并检查是否存在PR:
bash
undefined

Get current branch

Get current branch

git branch --show-current
git branch --show-current

Check for PR

Check for PR

gh --no-pager pr view <branch-name> --json number,title,url,state

If no PR exists, inform the user and offer to create one using the `create-pr` skill.
gh --no-pager pr view <branch-name> --json number,title,url,state

如果不存在PR,告知用户并提供使用`create-pr`技能创建PR的选项。

2. Check CI status

2. 检查CI状态

Fetch the status of all CI checks:
bash
gh pr view <branch-name> --json statusCheckRollup
Parse the output to identify:
  • Completed checks vs. in-progress checks
  • Successful checks
  • Failed checks with their names and details URLs
If CI is still running, inform the user which checks have already failed or passed, highlight the checks that are still running, and suggest waiting for completion before diagnosis.
获取所有CI检查的状态:
bash
gh pr view <branch-name> --json statusCheckRollup
解析输出以确定:
  • 已完成检查与进行中检查
  • 成功的检查
  • 失败的检查及其名称和详情URL
如果CI仍在运行,告知用户哪些检查已失败或通过,突出显示仍在运行的检查,并建议等待完成后再进行诊断。

3. Extract failure logs

3. 提取失败日志

For each failed check, pull the logs using the run ID from the status check:
bash
gh run view <run-id> --log-failed
Focus on extracting:
  • Error messages and their locations (file paths, line numbers)
  • Compilation errors (unused imports, type mismatches, etc.)
  • Linting/clippy errors with specific lint names
  • Test failure messages and stack traces
  • Build failures and their root causes
针对每个失败的检查,使用状态检查中的运行ID拉取日志:
bash
gh run view <run-id> --log-failed
重点提取:
  • 错误消息及其位置(文件路径、行号)
  • 编译错误(未使用的导入、类型不匹配等)
  • 带有特定lint名称的Linting/clippy错误
  • 测试失败消息和堆栈跟踪
  • 构建失败及其根本原因

4. Categorize errors

4. 错误分类

Group errors by type:
  • Formatting issues:
    cargo fmt
    failures
  • Linting issues:
    cargo clippy
    warnings/errors
  • Compilation errors: Type errors, missing imports, signature mismatches
  • Test failures: Failing tests with their names and failure reasons
  • Platform-specific issues: WASM, Linux, macOS, Windows-specific failures
按类型对错误进行分组:
  • 格式问题
    cargo fmt
    失败
  • Linting问题
    cargo clippy
    警告/错误
  • 编译错误:类型错误、缺失导入、签名不匹配
  • 测试失败:失败的测试及其名称和失败原因
  • 平台特定问题:WASM、Linux、macOS、Windows特定的失败

5. Generate fix plan

5. 生成修复方案

Create a plan document (using
create_plan
tool) with:
  • Problem Statement: Summary of failing checks
  • Current State: What errors were found and where
  • Proposed Changes: Specific fixes needed for each error category
  • Validation Steps: Commands to verify fixes (fmt, clippy, tests, presubmit)
The plan should reference the
fix-errors
skill for detailed guidance on resolving specific error types.
使用
create_plan
工具创建方案文档,包含:
  • 问题陈述:失败检查的摘要
  • 当前状态:发现的错误及其位置
  • 建议变更:每个错误类别所需的具体修复措施
  • 验证步骤:验证修复的命令(fmt、clippy、测试、预提交)
该方案应参考
fix-errors
技能以获取解决特定错误类型的详细指导。

Important Notes

重要说明

  • Always create a plan first: Never make code changes directly. Generate a plan for user review
  • Check test status in CI: Even if tests fail locally, verify they passed in CI before flagging as issues
  • Unrelated test failures: If tests passed in CI but fail locally, they may be environment-specific or flaky
  • Multiple error types: Fix one category at a time (e.g., all clippy errors before tests)
  • Cross-reference fix-errors skill: For detailed error resolution strategies, use the
    fix-errors
    skill
  • 始终先创建方案:切勿直接进行代码变更。生成方案供用户审核
  • 检查CI中的测试状态:即使测试在本地失败,也要验证它们在CI中是否通过,再标记为问题
  • 无关的测试失败:如果测试在CI中通过但在本地失败,可能是环境特定或不稳定的问题
  • 多种错误类型:一次修复一个类别(例如,先修复所有clippy错误再处理测试)
  • 交叉引用fix-errors技能:如需详细的错误解决策略,请使用
    fix-errors
    技能

Common CI Check Names

常见CI检查名称

  • Formatting + Clippy (MacOS)
  • Formatting + Clippy (Linux)
  • Run MacOS tests
  • Run Linux tests
  • Run Windows tests
  • Check CI results
    (summary check)
  • WASM build
  • Formatting + Clippy (MacOS)
  • Formatting + Clippy (Linux)
  • Run MacOS tests
  • Run Linux tests
  • Run Windows tests
  • Check CI results
    (summary check)
  • WASM build

Example Commands

示例命令

Get PR status with details:
bash
gh --no-pager pr view --json number,title,state,statusCheckRollup
Get logs from specific failed run:
bash
gh run view 12345678 --log-failed
Check for specific error in logs:
bash
gh run view 12345678 --log-failed 2>&1 | grep -A 5 "error:"
获取包含详情的PR状态:
bash
gh --no-pager pr view --json number,title,state,statusCheckRollup
从特定失败运行中获取日志:
bash
gh run view 12345678 --log-failed
在日志中查找特定错误:
bash
gh run view 12345678 --log-failed 2>&1 | grep -A 5 "error:"