Skip to content

Commit

Permalink
Merge pull request #21110 from wordpress-mobile/merge_junit_report
Browse files Browse the repository at this point in the history
Merge JUnit unit tests report
  • Loading branch information
wzieba authored Aug 6, 2024
2 parents b4a4ac0 + b1ba311 commit 2f712d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
34 changes: 17 additions & 17 deletions .buildkite/commands/run-unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/shared-pipeline-vars
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 2f712d1

Please sign in to comment.