Skip to content

Commit 9e5c941

Browse files
authored
Add Cursor agent CI fix workflow (#80)
## Summary - Adds a GitHub Actions workflow that automatically attempts to fix CI failures using cursor-agent - When the test workflow fails on a PR, this workflow analyzes the failure logs and proposes fixes via a compare link comment - Modeled after the existing fix-ci workflow in the kernel monorepo ## Test plan - [ ] Add `CURSOR_API_KEY` secret to the repository settings - [ ] Verify workflow triggers on next CI failure <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Introduces automated CI remediation via `cursor-agent` when the `Run tests for the CLI` workflow fails on PRs. > > - New `.github/workflows/fix-ci.yaml` triggers on failed `workflow_run` events and runs on `ubuntu-latest` > - Installs `cursor-agent`, configures git identity, sets up Go from `go.mod`, and uses `gh run view <id> --log-failed` for diagnostics > - Generates minimal fixes, pushes to `ci-fix/<pr-head-branch>`, and posts a PR-ready compare link as a comment > - Scoped permissions: `contents`/`pull-requests` write, `actions` read; avoids creating PRs directly and prevents duplicate comments > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7f03716. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2b80d06 commit 9e5c941

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.github/workflows/fix-ci.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Fix CI Failures
2+
3+
on:
4+
workflow_run:
5+
workflows: [Run tests for the CLI]
6+
types: [completed]
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
actions: read
12+
13+
jobs:
14+
attempt-fix:
15+
if: >-
16+
${{ github.event.workflow_run.conclusion == 'failure' &&
17+
github.event.workflow_run.event == 'pull_request' &&
18+
github.event.workflow_run.name != 'Fix CI Failures' }}
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Install Cursor CLI
27+
run: |
28+
curl https://cursor.com/install -fsS | bash
29+
echo "$HOME/.cursor/bin" >> $GITHUB_PATH
30+
31+
- name: Configure git identity
32+
run: |
33+
git config user.name "Cursor Agent"
34+
git config user.email "cursor-agent@onkernel.com"
35+
36+
- name: Setup Go
37+
uses: actions/setup-go@v5
38+
with:
39+
go-version-file: 'go.mod'
40+
41+
- name: Fix CI failure
42+
env:
43+
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
BRANCH_PREFIX: ci-fix
46+
run: |
47+
cursor-agent -p "You are operating in a GitHub Actions runner for the Kernel CLI repository.
48+
49+
The GitHub CLI is available as \`gh\` and authenticated via GH_TOKEN. Git is available. You have write access to repository contents and can comment on pull requests, but you must not create or edit PRs directly.
50+
51+
# Context
52+
- Repo: ${{ github.repository }}
53+
- Workflow Run ID: ${{ github.event.workflow_run.id }}
54+
- Workflow Run URL: ${{ github.event.workflow_run.html_url }}
55+
- Fix Branch Prefix: ci-fix
56+
57+
# Codebase Structure
58+
- cmd/ - CLI commands (main command implementations)
59+
- cmd/proxies/ - Proxy-related commands
60+
- cmd/mcp/ - MCP server commands
61+
- pkg/ - Supporting packages and templates
62+
- Makefile - Build and test targets (\`make test\` runs \`go vet\` and \`go test\`)
63+
64+
# Goal
65+
Implement an end-to-end CI fix flow: identify the failing PR, analyze the failure, make minimal targeted fixes, and propose changes back.
66+
67+
# Requirements
68+
1. Use \`gh run view ${{ github.event.workflow_run.id }} --log-failed\` to get failure logs
69+
2. Identify the PR associated with the failed workflow run
70+
3. Analyze the failure - common issues include:
71+
- Go compilation errors
72+
- Test failures (missing interface methods, type mismatches)
73+
- Mock/fake implementations missing new interface methods
74+
- Linting issues from \`go vet\`
75+
4. Make minimal, targeted edits consistent with the repo style
76+
5. Create/update a fix branch: ci-fix/<pr-head-branch>
77+
6. Push changes and post a PR comment with ONLY a compare link for quick PR creation
78+
- Format: Describe the fix, then provide ONLY a single PR creation link
79+
- Example format:
80+
\"🔧 CI Fix Available
81+
I've pushed a fix for the CI failure.
82+
83+
👉 Click here to create a PR with the fix\"
84+
- Do NOT include any git merge instructions or manual merge commands
85+
- Only include the compare link (e.g., https://github.com/.../compare/...)
86+
87+
# Style Guidelines
88+
- Go: Follow existing patterns, use testify for tests
89+
- Comments: Keep simple, no extra formatting
90+
- Interfaces: When adding methods to interfaces, update all implementations including test fakes
91+
92+
# Constraints
93+
- Do NOT create PRs directly - only post comments with compare links
94+
- Avoid duplicate comments - update existing bot comments
95+
- If no actionable fix is possible, make no changes and post no comment
96+
- PR comments must ONLY include the PR creation link, no manual merge instructions
97+
" --model opus-4.5 --force --output-format=text

0 commit comments

Comments
 (0)