{"data":{"slug":"discovered-25464e139415f5bd376d8b9dae2ffacb9aef7b6ad920ee09","title":"CI Diagnosis And Fix","summary":"Diagnose and fix GitHub Actions CI when workflows turn systematically red \u2014 systematic triage and repair flow for pipeline failures. Use when CI is failing wholesale, when asked to fix pipeline\/action errors, or when reviewing workflow configurations.","url":"https:\/\/skillshunter.net\/skills\/discovered-25464e139415f5bd376d8b9dae2ffacb9aef7b6ad920ee09","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-25464e139415f5bd376d8b9dae2ffacb9aef7b6ad920ee09","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-25464e139415f5bd376d8b9dae2ffacb9aef7b6ad920ee09.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-25464e139415f5bd376d8b9dae2ffacb9aef7b6ad920ee09\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"A GitHub Token with `repo` + `workflow` + `actions: read` permissions is required. Use the delimiter form for `$GITHUB_OUTPUT` to avoid compatibility issues on newer runners. Verify dependency resolution with `pip install -r requirements.txt --dry-run` after making changes.","instructions":"---\nname: ci-diagnosis-and-fix\ndescription: Diagnose and fix GitHub Actions CI when workflows turn systematically red \u2014 systematic triage and repair flow for pipeline failures. Use when CI is failing wholesale, when asked to fix pipeline\/action errors, or when reviewing workflow configurations. \u8bca\u65ad\u5e76\u4fee\u590d CI \u7cfb\u7edf\u6027\u53d8\u7ea2\u7684 GitHub Actions \u5de5\u4f5c\u6d41\u2014\u2014\u7ba1\u9053\u5931\u8d25\u7684\u7cfb\u7edf\u5316\u5206\u6d41\u4e0e\u4fee\u590d\u6d41\u7a0b\u3002\u5f53 CI \u6279\u91cf\u5931\u8d25\u3001\u8981\u6c42\u4fee\u590d pipeline\/action \u9519\u8bef\u6216\u5ba1\u67e5\u5de5\u4f5c\u6d41\u914d\u7f6e\u65f6\u4f7f\u7528\u3002\nkeywords: [ci, pipeline, github, action, workflow, build, \u6d41\u6c34\u7ebf, \u6784\u5efa, \"github actions\"]\n---\n# CI Failure Diagnosis & Repair\n\nWhen GitHub Actions CI turns systematically red, triage and fix it with this flow instead of patching workflows one at a time.\n\n## Flow Overview\n\n```\nTrigger (failed run notification \/ manual request)\n  \u2192 find the workflow run via the GitHub API\n  \u2192 pull the failing job's log\n  \u2192 classify the root cause\n  \u2192 fix\n  \u2192 verify\n```\n\n## Prerequisites\n\n- **GitHub Token** with `repo` + `workflow` + `actions: read` permissions (a classic PAT with `repo` scope suffices).\n\n## Diagnosis Flow (Step-by-Step)\n\n### 1. Find the failing workflow run\n\n```\nGET \/repos\/{owner}\/{repo}\/actions\/runs?per_page=10&status=failure\n```\n\nUse the token as a Bearer token. Focus on `run_number`, `name`, `head_branch`, `conclusion`, `html_url`. Prefer the most recent run on the branch you care about; check whether multiple workflows failed on the *same commit*.\n\n### 2. Find the failing job\n\n```\nGET \/repos\/{owner}\/{repo}\/actions\/runs\/{run_id}\/jobs\n```\n\nWalk `jobs[].steps[]` and locate the step with `conclusion == \"failure\"`.\n\n### 3. Download the failing step's log\n\n```\nGET \/repos\/{owner}\/{repo}\/actions\/runs\/{run_id}\/logs\n```\n\nReturns a zip; extract **only** the failing step's log, not everything (logs can be huge). Decode with `utf-8-sig` (GitHub logs carry a BOM). Read the last 2000\u20133000 characters of the failing step.\n\n### 4. Classify the root cause\n\n| Error signature | Common root cause | Fix direction |\n|---|---|---|\n| `No matching distribution found for X` | dependency version does not exist \/ incompatible | pin a released version or bump the CI Python |\n| `ModuleNotFoundError` | missing dependency \/ wrong import path | add the dependency or fix the import |\n| `assert ... failed` \/ red tests | code logic | fix the code |\n| `Process completed with exit code 1` (no clear error) | environment \/ timeout | read the full log |\n| `SyntaxError` \/ `TypeError` | Python version incompatibility | fix code or align versions |\n| `Timeout` | slow tests \/ network | raise the timeout or fix the slow path |\n\n**Multiple workflows failing at the same time on the same commit \u2192 almost always a dependency\/environment problem, not code.** One broken shared dependency cascades into \"everything red\".\n\n### 5. Compare history\n\nRepeated failures on the same branch over many runs \u2192 a persistent problem, not a flake. Check whether the last ~30 failed runs cluster on a specific commit range (a single broken merge).\n\n## Common Fixes\n\n### GITHUB_OUTPUT delimiter syntax\n\nThe old `echo \"k=v\" >> \"$GITHUB_OUTPUT\"` syntax fails on newer runners (`Invalid format`). Use the delimiter form, which works everywhere:\n\n```bash\n# Old (fails on Node 24 runners)\necho \"count=$ERROR_COUNT\" >> \"$GITHUB_OUTPUT\"\n\n# New (delimiter syntax)\necho \"count<<EOF\" >> \"$GITHUB_OUTPUT\"\necho \"$ERROR_COUNT\" >> \"$GITHUB_OUTPUT\"\necho \"EOF\" >> \"$GITHUB_OUTPUT\"\n```\n\n### Playwright E2E \u2014 let webServer manage the dev server\n\nIf `playwright.config.ts` already declares a `webServer`, do NOT start the app separately in the workflow \u2014 Playwright manages it.\n\n```yaml\n- name: Install Playwright browsers\n  run: npx playwright install chromium --with-deps\n- name: Run Playwright tests   # Playwright auto-starts webServer\n  run: npx playwright test\n  env:\n    CI: \"true\"\n```\n\n### Dependency files \u2014 surgical edits only\n\nRewrite only the offending line, never the whole file. `git show HEAD:requirements.txt` gives you the original; a full rewrite loses version pins and indirect dependencies.\n\n## Verification after a fix\n\n1. `pip install -r requirements.txt --dry-run` \u2014 confirm the dependency set resolves\n2. Grep every workflow that uses `$GITHUB_OUTPUT` and confirm it uses the delimiter form\n3. Confirm no duplicate dev-server starts \/ port conflicts (Playwright webServer vs manual start)\n\n## Notes\n\n- **Encoding**: Windows consoles default to cp1252; avoid `\u2717\u2713\u2605\u25c6` etc. in `print()` output, use `[FAIL]` \/ `[OK]` ASCII markers.\n- **BOM**: GitHub log zips carry a UTF-8 BOM (`\\ufeff`); decode with `utf-8-sig`.\n- **Token scope**: pulling logs requires `repo` + `workflow` (`actions: read`).\n- **Batch failure pattern**: many workflows red at the same commit \u21d2 dependency\/environment issue, not N separate code bugs.\n","use_cases":["Fixing GitHub Actions CI when workflows fail systematically","Diagnosing and resolving pipeline errors in GitHub Actions","Reviewing and repairing workflow configurations for GitHub Actions"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/chenyinrusi\/dsh-engineering-skills\/blob\/86d622bfbebb228269ad2b906c44069fd492397f\/skills\/ci-diagnosis-and-fix\/SKILL.md","source_commit":"86d622bfbebb228269ad2b906c44069fd492397f","license":null,"version":null,"listing_approved_at":"2026-11-28","created_at":"2026-11-28T07:59:15.000000Z","updated_at":"2026-11-28T18:37:41.000000Z","seo_title":"CI Diagnosis And Fix","seo_description":"Systematic triage and repair flow for GitHub Actions CI when workflows turn systematically red. Fix pipeline failures by identifying root causes, applying targeted fixes,","seo_keywords":["ci","pipeline","github","action","workflow","build","\u6d41\u6c34\u7ebf","\u6784\u5efa"]}}