diff --git a/.buildkite/commands/comment-claude-analysis.sh b/.buildkite/commands/comment-claude-analysis.sh new file mode 100755 index 000000000000..3acf4fc2ac1f --- /dev/null +++ b/.buildkite/commands/comment-claude-analysis.sh @@ -0,0 +1,11 @@ +#!/bin/bash -eu + +# Check if unit tests failed (matches both hard_failed and soft_failed outcomes) +if buildkite-agent step get outcome --step unit-tests | grep -q "failed"; then + comment_on_pr --id claude-test-analysis "## 🤖 Test Failure Analysis + +Your tests failed. Claude has analyzed the failures - check the annotation for details." +else + # Remove the comment if tests are now passing + comment_on_pr --id claude-test-analysis --if-exist delete +fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index a91c9a4ced48..95542dc5c8f2 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -83,15 +83,27 @@ steps: steps: - label: "Unit tests" + key: unit-tests command: .buildkite/commands/run-unit-tests.sh plugins: - $CI_TOOLKIT - $TEST_COLLECTOR : <<: *test_collector_common_params api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_UNIT_TESTS" + - $CLAUDE_PLUGIN: + api_key: "$ANTHROPIC_API_KEY" + buildkite_api_token: "$BUILDKITE_TOKEN_FOR_CLAUDE" artifact_paths: - "**/build/test-results/merged-test-results.xml" + - label: "💬 Comment Claude Analysis" + command: .buildkite/commands/comment-claude-analysis.sh + depends_on: unit-tests + allow_dependency_failure: true + if: build.pull_request.id != null + plugins: + - $CI_TOOLKIT + - label: "Instrumented tests" command: .buildkite/commands/run-instrumented-tests.sh plugins: diff --git a/.buildkite/shared-pipeline-vars b/.buildkite/shared-pipeline-vars index 0b46446fba6d..08d9e22a5a23 100644 --- a/.buildkite/shared-pipeline-vars +++ b/.buildkite/shared-pipeline-vars @@ -5,3 +5,4 @@ export CI_TOOLKIT="automattic/a8c-ci-toolkit#5.4.0" export TEST_COLLECTOR="test-collector#v1.10.1" +export CLAUDE_PLUGIN="claude-summarize#v1.1.0"