|
| 1 | +# Debug GitHub CI |
| 2 | + |
| 3 | +Automated debugging of GitHub Actions CI failures using OpenHands agents. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This extension provides **dual-mode functionality**: |
| 8 | + |
| 9 | +1. **Skill Mode**: A knowledge skill (`SKILL.md`) that provides guidance and context for debugging CI failures interactively via OpenHands conversations. |
| 10 | + |
| 11 | +2. **Plugin Mode**: An executable GitHub Action (`action.yml`) that can be triggered automatically when CI fails, running an autonomous debug agent. |
| 12 | + |
| 13 | +Use **skill mode** when working interactively with OpenHands to debug CI issues. Use **plugin mode** to automate CI failure analysis in your GitHub workflows. |
| 14 | + |
| 15 | +## Quick Start |
| 16 | + |
| 17 | +Copy the workflow file to your repository: |
| 18 | + |
| 19 | +```bash |
| 20 | +mkdir -p .github/workflows |
| 21 | +curl -o .github/workflows/debug-ci-failure.yml \ |
| 22 | + https://raw.githubusercontent.com/OpenHands/extensions/main/plugins/debug-github-ci/workflows/debug-ci-failure.yml |
| 23 | +``` |
| 24 | + |
| 25 | +Then configure the required secrets (see [Installation](#installation) below). |
| 26 | + |
| 27 | +## Features |
| 28 | + |
| 29 | +- **Automatic CI Failure Analysis**: Triggered when workflow runs fail |
| 30 | +- **Log Analysis**: Fetches and analyzes failed job logs to identify root causes |
| 31 | +- **Actionable Suggestions**: Posts comments with specific fixes and commands |
| 32 | +- **Error Pattern Recognition**: Identifies common CI failure patterns |
| 33 | +- **Context-Aware**: Considers recent commits and PR changes |
| 34 | + |
| 35 | +## Plugin Contents |
| 36 | + |
| 37 | +``` |
| 38 | +plugins/debug-github-ci/ |
| 39 | +├── README.md # This file |
| 40 | +├── action.yml # Composite GitHub Action |
| 41 | +├── skills/ # Symbolic links to debug skills |
| 42 | +│ └── debug-github-ci -> ../../../skills/debug-github-ci |
| 43 | +├── workflows/ # Example GitHub workflow files |
| 44 | +│ └── debug-ci-failure.yml |
| 45 | +└── scripts/ # Python scripts for debug execution |
| 46 | + ├── agent_script.py # Main CI debug agent script |
| 47 | + └── prompt.py # Prompt template for debugging |
| 48 | +``` |
| 49 | + |
| 50 | +## Installation |
| 51 | + |
| 52 | +### 1. Copy the Workflow File |
| 53 | + |
| 54 | +Copy the workflow file to your repository's `.github/workflows/` directory: |
| 55 | + |
| 56 | +```bash |
| 57 | +mkdir -p .github/workflows |
| 58 | +curl -o .github/workflows/debug-ci-failure.yml \ |
| 59 | + https://raw.githubusercontent.com/OpenHands/extensions/main/plugins/debug-github-ci/workflows/debug-ci-failure.yml |
| 60 | +``` |
| 61 | + |
| 62 | +### 2. Configure Secrets |
| 63 | + |
| 64 | +Add the following secrets in your repository settings (**Settings → Secrets and variables → Actions**): |
| 65 | + |
| 66 | +| Secret | Required | Description | |
| 67 | +|--------|----------|-------------| |
| 68 | +| `LLM_API_KEY` | Yes | API key for your LLM provider | |
| 69 | +| `GITHUB_TOKEN` | Auto | Provided automatically by GitHub Actions | |
| 70 | + |
| 71 | +### 3. Customize the Workflow (Optional) |
| 72 | + |
| 73 | +Edit the workflow file to customize: |
| 74 | + |
| 75 | +```yaml |
| 76 | +- name: Debug CI Failure |
| 77 | + uses: OpenHands/extensions/plugins/debug-github-ci@main |
| 78 | + with: |
| 79 | + # LLM model to use |
| 80 | + llm-model: anthropic/claude-sonnet-4-5-20250929 |
| 81 | + |
| 82 | + # Secrets |
| 83 | + llm-api-key: ${{ secrets.LLM_API_KEY }} |
| 84 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 85 | +``` |
| 86 | +
|
| 87 | +## Usage |
| 88 | +
|
| 89 | +### Automatic Triggers |
| 90 | +
|
| 91 | +CI debugging is automatically triggered when: |
| 92 | +
|
| 93 | +1. A workflow run fails on the repository |
| 94 | +2. The `debug-ci` label is added to a PR with failed checks |
| 95 | + |
| 96 | +### Manual Trigger |
| 97 | + |
| 98 | +You can manually trigger debugging: |
| 99 | + |
| 100 | +1. Go to **Actions** tab |
| 101 | +2. Select **Debug CI Failure** workflow |
| 102 | +3. Click **Run workflow** |
| 103 | +4. Enter the failed run ID |
| 104 | + |
| 105 | +## Action Inputs |
| 106 | + |
| 107 | +| Input | Required | Default | Description | |
| 108 | +|-------|----------|---------|-------------| |
| 109 | +| `llm-model` | No | `anthropic/claude-sonnet-4-5-20250929` | LLM model to use | |
| 110 | +| `llm-base-url` | No | `''` | Custom LLM endpoint URL | |
| 111 | +| `run-id` | No | Auto | Specific workflow run ID to debug | |
| 112 | +| `extensions-repo` | No | `OpenHands/extensions` | Extensions repository | |
| 113 | +| `extensions-version` | No | `main` | Git ref (tag, branch, or SHA) | |
| 114 | +| `llm-api-key` | Yes | - | LLM API key | |
| 115 | +| `github-token` | Yes | - | GitHub token for API access | |
| 116 | + |
| 117 | +## What Gets Analyzed |
| 118 | + |
| 119 | +The agent analyzes: |
| 120 | + |
| 121 | +1. **Failed job logs**: Console output from failed steps |
| 122 | +2. **Error messages**: Specific error patterns and stack traces |
| 123 | +3. **Recent commits**: Changes that may have caused the failure |
| 124 | +4. **Workflow configuration**: Issues in the workflow YAML |
| 125 | +5. **Dependencies**: Version conflicts or missing packages |
| 126 | + |
| 127 | +## Output |
| 128 | + |
| 129 | +The agent posts a comment with: |
| 130 | + |
| 131 | +- **Root Cause Analysis**: What caused the failure |
| 132 | +- **Suggested Fixes**: Specific commands or code changes |
| 133 | +- **Prevention Tips**: How to avoid similar failures |
| 134 | + |
| 135 | +## Troubleshooting |
| 136 | + |
| 137 | +### Debug Not Triggered |
| 138 | + |
| 139 | +1. Ensure the workflow file is in `.github/workflows/` |
| 140 | +2. Verify secrets are configured correctly |
| 141 | +3. Check that the workflow has `workflow_run` trigger permissions |
| 142 | + |
| 143 | +### Analysis Incomplete |
| 144 | + |
| 145 | +1. Check if logs are available (some expire after 90 days) |
| 146 | +2. Verify the `GITHUB_TOKEN` has read access to workflow logs |
| 147 | +3. Increase timeout if analysis takes too long |
| 148 | + |
| 149 | +## Security |
| 150 | + |
| 151 | +- Uses `workflow_run` event for secure access to secrets |
| 152 | +- Only analyzes public workflow logs |
| 153 | +- Does not execute any code from the failed run |
| 154 | + |
| 155 | +## Contributing |
| 156 | + |
| 157 | +See the main [extensions repository](https://github.com/OpenHands/extensions) for contribution guidelines. |
| 158 | + |
| 159 | +## License |
| 160 | + |
| 161 | +This plugin is part of the OpenHands extensions repository. See [LICENSE](../../LICENSE) for details. |
0 commit comments