diff --git a/.buildkite/commands/run-unit-tests.sh b/.buildkite/commands/run-unit-tests.sh index c8ee2cf56788..fa7b763f9d9c 100755 --- a/.buildkite/commands/run-unit-tests.sh +++ b/.buildkite/commands/run-unit-tests.sh @@ -4,15 +4,18 @@ echo "--- ๐Ÿงช Testing" set +e if [ "$1" == "wordpress" ]; then test_suite="testWordpressVanillaRelease koverXmlReportWordpressVanillaRelease" - test_log_dir="WordPress/build/test-results/*/*.xml" + test_results_dir="WordPress/build/test-results" + test_log_dir="${test_results_dir}/*/*.xml" code_coverage_report="WordPress/build/reports/kover/reportWordpressVanillaRelease.xml" elif [ "$1" == "processors" ]; then test_suite=":libs:processors:test :libs:processors:koverXmlReport" - test_log_dir="libs/processors/build/test-results/test/*.xml" + test_results_dir="libs/processors/build/test-results" + test_log_dir="${test_results_dir}/test/*.xml" code_coverage_report="libs/processors/build/reports/kover/report.xml" elif [ "$1" == "image-editor" ]; then test_suite=":libs:image-editor:testReleaseUnitTest :libs:image-editor:koverXmlReportRelease" - test_log_dir="libs/image-editor/build/test-results/testReleaseUnitTest/*.xml" + test_results_dir="libs/image-editor/build/test-results" + test_log_dir="${test_results_dir}/testReleaseUnitTest/*.xml" code_coverage_report="libs/image-editor/build/reports/kover/reportRelease.xml" else echo "Invalid Test Suite! Expected 'wordpress', 'processors', or 'image-editor', received '$1' instead" @@ -31,23 +34,20 @@ if [[ "$TESTS_EXIT_STATUS" -ne 0 ]]; then fi echo "--- ๐Ÿšฆ Report Tests Status" -path_pattern="*/build/test-results/*/*.xml" -results_files=() -while IFS= read -r -d '' file; do - results_files+=("$file") -done < <(find . -path "$path_pattern" -type f -name "*.xml" -print0) - -for file in "${results_files[@]}"; do - if [[ $BUILDKITE_BRANCH == trunk ]] || [[ $BUILDKITE_BRANCH == release/* ]]; then - annotate_test_failures "$file" --slack "build-and-ship" - else - annotate_test_failures "$file" - fi -done +results_file="$test_results_dir/merged-test-results.xml" + +# Merge JUnit results into a single file (for performance reasons with reporting) +merge_junit_reports -d ${test_log_dir%/*} -o $results_file + +if [[ $BUILDKITE_BRANCH == trunk ]] || [[ $BUILDKITE_BRANCH == release/* ]]; then + annotate_test_failures "$results_file" --slack "build-and-ship" +else + annotate_test_failures "$results_file" +fi echo "--- ๐Ÿงช Copying test logs for test collector" mkdir buildkite-test-analytics -cp $test_log_dir buildkite-test-analytics +cp $results_file buildkite-test-analytics echo "--- โš’๏ธ Uploading code coverage" .buildkite/commands/upload-code-coverage.sh $code_coverage_report diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 1dc4ba2f854a..54fb5526032a 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -85,7 +85,7 @@ steps: <<: *test_collector_common_params api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_UNIT_TESTS_WORDPRESS" artifact_paths: - - "**/build/test-results/*/*.xml" + - "**/build/test-results/merged-test-results.xml" - label: "๐Ÿ”ฌ Unit Test Processors" command: ".buildkite/commands/run-unit-tests.sh processors" @@ -95,7 +95,7 @@ steps: <<: *test_collector_common_params api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_UNIT_TESTS_PROCESSORS" artifact_paths: - - "**/build/test-results/*/*.xml" + - "**/build/test-results/merged-test-results.xml" - label: "๐Ÿ”ฌ Unit Test Image Editor" command: ".buildkite/commands/run-unit-tests.sh image-editor" @@ -105,7 +105,7 @@ steps: <<: *test_collector_common_params api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_UNIT_TESTS_IMAGE_EDITOR" artifact_paths: - - "**/build/test-results/*/*.xml" + - "**/build/test-results/merged-test-results.xml" ################# # Instrumented (aka UI) Tests diff --git a/.buildkite/shared-pipeline-vars b/.buildkite/shared-pipeline-vars index 2dbbc02e7912..00e32e0923c8 100644 --- a/.buildkite/shared-pipeline-vars +++ b/.buildkite/shared-pipeline-vars @@ -3,5 +3,5 @@ # This file is `source`'d before calling `buildkite-agent pipeline upload`, and can be used # to set up some variables that will be interpolated in the `.yml` pipeline before uploading it. - export CI_TOOLKIT="automattic/a8c-ci-toolkit#3.4.2" + export CI_TOOLKIT="automattic/a8c-ci-toolkit#3.5.0" export TEST_COLLECTOR="test-collector#v1.10.1"