diff --git a/.github/workflows/upload-test-results.yml b/.github/workflows/upload-test-results.yml index d66e8a969bd31c..00b3b33f0e58be 100644 --- a/.github/workflows/upload-test-results.yml +++ b/.github/workflows/upload-test-results.yml @@ -60,7 +60,7 @@ jobs: # 3. Remove system-err and system-out, because they cannot be easily parsed and add significant bloat, making storing and processing the data much more costly. # 4. Remove properties, because they leak secret values. # 5. Truncate all strings to 1k characters to avoid having lines longer than 100MB. - yq_opts=( + yq_surefire=( --input-format=xml --output-format=json --xml-attribute-prefix='' @@ -69,15 +69,28 @@ jobs: --xml-skip-proc-inst '.testsuite.testcase |= ([] + .) | .testsuite.testcase[] |= del(.system-err, .system-out) | .testsuite |= del(.properties) | .. |= select(tag == "!!str") |= sub("(.{0,1000}).*", "${1}")' ) + # 1. Don't prefix attributes, because +@ (the default prefix) is not a valid character in nested row field names in the Hive connector for JSON files. + # 2. Convert dashes to underscores in all map keys. + # 3. Make sure all arrays with only one item never get converted to an object + # 4. Truncate all strings to 1k characters to avoid having lines longer than 100MB. + yq_testng=( + --input-format=xml + --output-format=json + --xml-attribute-prefix='' + --xml-content-name='content' + --xml-skip-directives + --xml-skip-proc-inst + '.. |= select(tag == "!!map") |= with_entries(.key |= sub("-", "_")) | .suite.group.method |= ([] + .) | .suite.test.class[].test_method |= ([] + .) | .suite.test.class[].test_method[].params |= ([] + .) | .. |= select(tag == "!!str") |= sub("(.{0,1000}).*", "${1}")' + ) artifact_id='${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}.json.gz' find . \ -name TEST-\*.xml \ - -exec yq "${yq_opts[@]}" {} \; \ + -exec yq "${yq_surefire[@]}" {} \; \ | jq -c > surefire.ndjson find . \ -name testng-results.xml \ - -exec yq "${yq_opts[@]}" {} \; \ + -exec yq "${yq_testng[@]}" {} \; \ | jq -c > testng.ndjson for filename in *.ndjson; do