-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Tooling] Add Claude Build Analysis to any failing build job #25104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
6a84686
c9f6e28
5e61c83
7a21351
8fe005a
cc6e119
2f8c9a5
9b8c843
5c6f962
e349939
d3aa906
0b0f017
6da7c41
d6cc669
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json | ||
| --- | ||
|
|
||
| # This pipeline is dynamically uploaded at the end of the build after a wait step | ||
|
|
||
| agents: | ||
| queue: default | ||
|
|
||
| steps: | ||
| - label: ":claude: Claude Build Analysis" | ||
| key: claude-analysis | ||
| if: build.state == "failing" | ||
| soft_fail: true | ||
| command: "exit 1" | ||
| artifact_paths: | ||
| - "/tmp/claude_debug_${BUILDKITE_BUILD_ID}.txt" | ||
| - "/tmp/claude_response_${BUILDKITE_BUILD_ID}.json" | ||
| - "/tmp/buildkite_logs_${BUILDKITE_BUILD_ID}.txt" | ||
| plugins: | ||
| - $CLAUDE_PLUGIN: | ||
| api_key: "$ANTHROPIC_API_KEY" | ||
| buildkite_api_token: "$BUILDKITE_TOKEN_FOR_CLAUDE" | ||
| analysis_level: "build" | ||
| build_log_mode: "failed" | ||
| trigger: "on-failure" | ||
| max_log_lines: 1500 | ||
| custom_prompt: "Do not mention successful points, focus on failures and recovery to keep the analysis succinct. Only add the `Best Practices` section if the changes in this PR are directly relevant to it. Only add a `Root Cause` section when you're sure about the issues' causes." | ||
| model: "claude-sonnet-4-5" | ||
|
|
||
| - label: ":claude: 💬 Comment Claude Analysis" | ||
| command: .buildkite/commands/comment-claude-analysis.sh | ||
| depends_on: claude-analysis | ||
| allow_dependency_failure: true | ||
| if: build.pull_request.id != null | ||
| plugins: | ||
| - $CI_TOOLKIT_PLUGIN | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/bin/bash -eu | ||
|
|
||
| # The claude-analysis step only runs when there are build failures, | ||
| # so if it ran (and soft_failed), it means there were failures that Claude analyzed. | ||
| CLAUDE_OUTCOME=$(buildkite-agent step get outcome --step claude-analysis 2>/dev/null || echo "not_run") | ||
|
|
||
| if [[ "${CLAUDE_OUTCOME}" == "soft_failed" ]]; then | ||
| comment_on_pr --id claude-build-analysis "## 🤖 Build Failure Analysis | ||
|
|
||
| This build has failures. Claude has analyzed them - <a href=\"${BUILDKITE_BUILD_URL}/annotations\" target=\"_blank\">check the build annotations</a> for details." | ||
| else | ||
| # Remove the comment if the build is now passing (claude-analysis did not run) | ||
| comment_on_pr --id claude-build-analysis --if-exist delete | ||
| fi | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ CI_TOOLKIT_PLUGIN_VERSION="5.3.1" | |
|
|
||
| export IMAGE_ID="xcode-$XCODE_VERSION" | ||
| export CI_TOOLKIT_PLUGIN="automattic/a8c-ci-toolkit#$CI_TOOLKIT_PLUGIN_VERSION" | ||
| export CLAUDE_PLUGIN="iangmaia/claude-summarize#iangmaia/add-build-log-mode" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've created a Pull Request to the claude-summarize-buildkite-plugin project introducing the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise, we can always keep using or fork, whic I think you mentioned this elsewhere, too. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why commenting the whole step?
I mean, it makes sense so the parser doesn't have to bother with something that is hardcoded
if: "false"and the result is the same, but was it to help with this PR or something that stood out?Perhaps given the commit it the change is in, e349939, it was to reduce the logs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this was a minor issue -- in the state summary of all jobs that I implemented in the fork, I noticed the status for this job was something weird (
Keystone Unit Tests: exit_status=pending, state=broken) that Claude was picking up as an error and polluting a little bit the analysis with a red herring.