diff --git a/.buildkite/commands/comment-claude-analysis.sh b/.buildkite/commands/comment-claude-analysis.sh new file mode 100755 index 000000000000..e0da840c918e --- /dev/null +++ b/.buildkite/commands/comment-claude-analysis.sh @@ -0,0 +1,16 @@ +#!/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 "$(cat <check the annotation for details. +EOF +)" + +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 9bb2ac013346..0c14e5e8bbff 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -102,16 +102,28 @@ steps: # Unit Tests ################# - 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_WORDPRESS" + - $CLAUDE_PLUGIN: + api_key: "$ANTHROPIC_API_KEY" + buildkite_api_token: "$BUILDKITE_TOKEN_FOR_CLAUDE" artifact_paths: - "**/build/test-results/merged-test-results.xml" - "**/build/reports/kover/*.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 + ################# # Instrumented (aka UI) Tests ################# diff --git a/.buildkite/shared-pipeline-vars b/.buildkite/shared-pipeline-vars index 065407d8fd12..ab38b2885310 100644 --- a/.buildkite/shared-pipeline-vars +++ b/.buildkite/shared-pipeline-vars @@ -5,3 +5,4 @@ export CI_TOOLKIT="automattic/a8c-ci-toolkit#5.3.1" export TEST_COLLECTOR="test-collector#v1.10.1" +export CLAUDE_PLUGIN="claude-summarize#v1.1.0"