feat: Add check_run webhook support for CI failure auto-remediation#1558
feat: Add check_run webhook support for CI failure auto-remediation#1558knechtionscoding wants to merge 2 commits into
Conversation
Extend the GitHub webhook path to handle check_run events so a TaskSpawner can watch for a specific failing CI check and dispatch an agent to fix it. - Add conclusion and checkName filter fields to GitHubWebhookFilter (v1alpha2) - Parse check_run events (name, head SHA, URL, associated PR branch/number) - Match check_run events by conclusion (exact) and checkName (glob) - Expose CheckName, Conclusion, CheckRunURL, HeadSHA, CheckApp template vars - Map check_run to the pull-request reporting source when linked to a PR - Regenerate CRDs; add filter, parse, extract, and conversion tests - Document the new fields and add a CI-remediation example Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 12 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
@gjkim42 relatively small one, but ready for review |
|
/kelos api-review |
|
🤖 Kelos Task Status Task |
|
🤖 Kelos API Reviewer Agent @gjkim42 API Design ReviewVerdict: REQUEST CHANGES FindingsCompatibility
Validation
Documentation
Suggestions
/kelos needs-input |
|
Since it's alpha, we don't want to consider the droped fields by roundtrip. |
|
/kelos review |
|
🤖 Kelos Task Status Task |
|
🤖 Kelos Reviewer Agent @gjkim42 Review SummaryVerdict: REQUEST CHANGES Findings Overview
FindingsCorrectness
Tests
Key takeaways
|
- Drop excludeAuthors from the example: a check_run sender is the CI app, and spawner-level excludeAuthors runs before filters, so it dropped every event - Name the Task by check run ID so redeliveries collapse while reruns and new commits get their own Task, instead of naming by PR number - Render PR-dependent template vars via index / if-index so check runs without a linked PR no longer fail Task construction under missingkey=error - Add TestWebhookSourceKind cases for linked and unlinked check runs - Add ExtractGitHubWorkItem test asserting Branch/Number are omitted when a check_run has no linked PR Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds first-class support for CI/CD failure auto-remediation by teaching the
GitHub webhook path to understand
check_runevents. Previouslycheck_runevents fell through to the generic default handler (only
sender+actionextracted), and
GitHubWebhookFilterhad no way to filter by conclusion orcheck name — so a CI auto-fix spawner would trigger on every completed check run
(pass or fail) and could not distinguish lint from test from build failures.
This PR makes the framework changes needed to build a spawner that watches for a
specific failing check and dispatches an agent to fix it, all additive and
backward-compatible:
api/v1alpha2): two new optional fields onGitHubWebhookFilter:conclusion— filterscheck_runevents by conclusion (kubebuilder enum:success,failure,cancelled,timed_out,action_required,neutral,skipped,stale).checkName— filterscheck_runevents by check run name (exact match orglob, e.g.
lint,build-*).ParseGitHubWebhook): a*github.CheckRunEventcase thatpopulates repository info,
Title(check name),HeadSHA,URL, and theassociated PR
Branch/Number.matchesFilterWithoutFilePatterns): conclusion (exact) andcheckName (glob) matching for
check_runevents.ExtractGitHubWorkItem): new CI-specific variables{{.CheckName}},{{.Conclusion}},{{.CheckRunURL}},{{.HeadSHA}},{{.CheckApp}}.webhookSourceKind): mapscheck_runtopull-requestwhenthe check is linked to a PR, so status reporting attaches to the PR.
go-github/v66already providesgithub.CheckRunEvent, so no new dependency isintroduced.
Which issue(s) this PR is related to:
Fixes #946
Special notes for your reviewer:
api/v1alpha2(the currentserved/storage version). The issue text referenced
api/v1alpha1, whichpredates the version bump; per project convention new API surface lands only
in the latest version. Conversion is a JSON round-trip, so the new
v1alpha2-only fields are dropped cleanly on down-conversion to v1alpha1
(covered by
TestTaskSpawnerConvert_CheckRunFilterFieldsDownConvert).check_run. The godoc hints thatworkflow_runsharesconclusionvalues, but that is intentionally left as a follow-up rather thanadding speculative API.
GitHubWebhookFilteris used by both TaskSpawner andSessionSpawner, so the regenerated CRDs for both pick up the new fields.
polling approach (
checkConclusion/checkNameson thegithubPullRequestssource). This PR implements the webhook/push approach from New use case: CI/CD failure auto-remediation pipeline via check_run webhook events — with GitHubWebhookFilter extensions for conclusion-based filtering #946. If this is
merged, New use case: CI-failure-driven agent remediation with check status filtering on githubPullRequests #809 should likely be closed as superseded.
check_runparsing, conclusion/checkName matching (includinga positive happy-path case), event-type-not-allowed, template-variable
extraction, and the conversion down-convert test. Docs
(
docs/reference.md) and a runnable example(
examples/17-taskspawner-ci-remediation/) are included.make verifyandmake test— both pass.Does this PR introduce a user-facing change?
Summary by cubic
Adds first-class
check_runwebhook support to enable CI failure auto-remediation. Spawners can now target specific failing checks by conclusion and name with better context for templates and reporting.api/v1alpha2: add optionalconclusionandcheckNametoGitHubWebhookFilterforcheck_runevents (exact and glob match).check_runpayloads to extract repo, check name (Title),HeadSHA,URL, and linked PRBranch/Number.check_runevents byconclusion(exact) andcheckName(glob).CheckName,Conclusion,CheckRunURL,HeadSHA,CheckApp.check_runtopull-requestreporting when linked; regenerate CRDs; add docs/tests and an example (examples/17-taskspawner-ci-remediation) that names tasks by check run ID, removesexcludeAuthors, and guards PR-less runs withindex/if.Written for commit d0f57bf. Summary will update on new commits.