Skip to content

Commit 75e9eaf

Browse files
actions(build): unify test results and summaries into a single tarball for each test run
Instead of uploading our failure summaries and test results files directly to Github Actions storage, instead we create a unified gzipped tarball with all of the files. This is useful because - The Summary tab of the workflow is already polluted with too much information. I really only want to see what failed. That doesn't completed address that but it's a first step. - The Summary tab has loads of files attached that aren't the actual artifacts. This actually impacts CRT further down the line when it downloads these files and uploads them to Artifactory. We're hoping that by creating our own archive that might help an issue we've been seeing lately. - When I want debug/test information for a test scenario I can almost get everything in a single bundle. Future enhancement might be to also include the enos debug object files in this too. Signed-off-by: Ryan Cragun <me@ryan.ec> Co-authored-by: Ryan Cragun <me@ryan.ec>
1 parent 2b1f8ef commit 75e9eaf

2 files changed

Lines changed: 101 additions & 43 deletions

File tree

.github/workflows/build.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,48 @@ jobs:
731731
fi
732732
- id: slackbot-webhook-url
733733
run:
734-
echo "slackbot-webhook-url=${{ needs.setup.outputs.is-ent-repo != 'true' && secrets.FEED_VAULT_CI_OFFICIAL_WEBHOOK_URL || steps.secrets.outputs.slackbot-webhook-url }}" >> "$GITHUB_OUTPUT"
734+
echo "slackbot-webhook-url=${{ needs.setup.outputs.is-ent-repo != 'true' && secrets.FEED_VAULT_CI_OFFICIAL_WEBHOOK_URL || steps.secrets.outputs.slackbot-webhook-url }}" | tee -a "$GITHUB_OUTPUT"
735735
- if: ${{ needs.setup.outputs.is-fork == 'false' }}
736-
name: Download failure summaries
736+
name: Download test results tarballs
737737
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
738738
with:
739-
pattern: failure-summary-*.md
740-
path: failure-summaries
739+
pattern: test-results_*.tar.gz
740+
path: test-results-tarballs
741741
merge-multiple: true
742+
- if: ${{ needs.setup.outputs.is-fork == 'false' }}
743+
name: Extract test results and failure summaries
744+
run: |
745+
mkdir -p failure-summaries
746+
extraction_errors=0
747+
748+
if [ -d "test-results-tarballs" ]; then
749+
for tarball in test-results-tarballs/*.tar.gz; do
750+
if [ -f "$tarball" ]; then
751+
temp_extract_dir=$(mktemp -d)
752+
753+
# Extract tarball with error checking
754+
if ! tar -xzf "$tarball" -C "$temp_extract_dir"; then
755+
echo "::error file=$(basename "$tarball")::Failed to extract tarball"
756+
extraction_errors=$((extraction_errors + 1))
757+
rm -rf "$temp_extract_dir"
758+
continue
759+
fi
760+
761+
# Copy failure summaries if they exist
762+
if [ -d "$temp_extract_dir/failure_summary" ]; then
763+
if ls "$temp_extract_dir/failure_summary"/*.md &>/dev/null; then
764+
cp "$temp_extract_dir/failure_summary"/*.md failure-summaries/
765+
fi
766+
fi
767+
768+
rm -rf "$temp_extract_dir"
769+
fi
770+
done
771+
772+
if [ $extraction_errors -gt 0 ]; then
773+
echo "::error::Failed to extract $extraction_errors tarball(s)"
774+
fi
775+
fi
742776
- if: ${{ needs.setup.outputs.is-fork == 'false' }}
743777
id: prepare-failure-summary
744778
name: Prepare failure summary

.github/workflows/test-run-enos-scenario-matrix.yml

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -342,43 +342,17 @@ jobs:
342342
if-no-files-found: ignore
343343
continue-on-error: true
344344

345-
- name: Upload Test Results
345+
- name: Prepare Test Results and Failure Summaries
346346
if: always()
347-
id: upload_test_results
348-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
349-
with:
350-
name: ${{ steps.prepare_scenario.outputs.test_results_artifact_name }}
351-
path: /tmp/vault_test_results_*.json
352-
retention-days: 7
353-
if-no-files-found: ignore
354-
continue-on-error: true
355-
356-
- name: Upload JUnit Test Results
357-
if: always()
358-
id: upload_junit_results
359-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
360-
with:
361-
name: ${{ steps.prepare_scenario.outputs.junit_results_artifact_name }}
362-
path: /tmp/vault_test_results_*.xml
363-
retention-days: 7
364-
if-no-files-found: ignore
365-
continue-on-error: true
366-
367-
- name: Check for test results
368-
if: always()
369-
id: check_test_results
347+
id: prepare_test_summary
370348
continue-on-error: true
371349
run: |
372-
if find /tmp -maxdepth 1 -name 'vault_test_results_*.json' -type f -print -quit 2>/dev/null | grep -q .; then
373-
echo "has_results=true" >> "$GITHUB_OUTPUT"
374-
else
375-
echo "has_results=false" >> "$GITHUB_OUTPUT"
350+
if ! find /tmp -maxdepth 1 -name 'vault_test_results_*.json' -type f -print -quit 2>/dev/null | grep -q .; then
351+
echo "failure_summary_created=false" | tee -a "$GITHUB_OUTPUT"
352+
echo "::warning::No test results found in /tmp/vault_test_results_*.json"
353+
exit 0
376354
fi
377355
378-
- name: Prepare Test Results Summary
379-
if: always() && steps.check_test_results.outputs.has_results == 'true'
380-
continue-on-error: true
381-
run: |
382356
# Find the most recent JSON test results file
383357
json_file=$(find /tmp -maxdepth 1 -name 'vault_test_results_*.json' -type f -printf '%T@ %p\n' 2>/dev/null | sort -rn | head -n1 | cut -d' ' -f2-)
384358
@@ -396,6 +370,9 @@ jobs:
396370
passed_tests=$(jq -r 'select(.Action == "pass") | select(.Test != null)' "$json_file" | jq -s 'length')
397371
failed_tests=$(jq -r 'select(.Action == "fail") | select(.Test != null)' "$json_file" | jq -s 'length')
398372
373+
# Output for use in tarball creation
374+
echo "failure_summary_created=true" | tee -a "$GITHUB_OUTPUT"
375+
399376
# Create step summary for this specific scenario
400377
{
401378
echo "## Test Results for ${{ matrix.scenario.id.filter }}"
@@ -414,19 +391,66 @@ jobs:
414391
cat "${failure_summary_file}"
415392
echo ""
416393
fi
394+
} | tee -a "$GITHUB_STEP_SUMMARY"
395+
else
396+
echo "failure_summary_created=false" | tee -a "$GITHUB_OUTPUT"
397+
fi
398+
399+
- name: Create test results tarball
400+
if: always()
401+
id: create_test_results_tarball
402+
continue-on-error: true
403+
run: |
404+
mkdir -p /tmp/test-artifacts/test_results
405+
mkdir -p /tmp/test-artifacts/junit_results
406+
mkdir -p /tmp/test-artifacts/failure_summary
417407
418-
echo "📊 Full test results available in artifacts: \`${{ steps.prepare_scenario.outputs.test_results_artifact_name }}\`"
419-
} >> "$GITHUB_STEP_SUMMARY"
408+
if ls /tmp/vault_test_results_*.json 1> /dev/null 2>&1; then
409+
cp /tmp/vault_test_results_*.json /tmp/test-artifacts/test_results/
410+
fi
411+
412+
if ls /tmp/vault_test_results_*.xml 1> /dev/null 2>&1; then
413+
cp /tmp/vault_test_results_*.xml /tmp/test-artifacts/junit_results/
414+
fi
415+
416+
failure_summary_file="${{ steps.prepare_scenario.outputs.failure_summary_artifact_name }}"
417+
if [ "${{ steps.prepare_test_summary.outputs.failure_summary_created }}" == "true" ] && [ -f "$failure_summary_file" ]; then
418+
cp "$failure_summary_file" /tmp/test-artifacts/failure_summary/
419+
fi
420+
421+
if [ -n "$(ls -A /tmp/test-artifacts/test_results 2>/dev/null)" ] || \
422+
[ -n "$(ls -A /tmp/test-artifacts/junit_results 2>/dev/null)" ] || \
423+
[ -n "$(ls -A /tmp/test-artifacts/failure_summary 2>/dev/null)" ]; then
424+
scenario_safe_name=$(echo "${{ matrix.scenario.id.filter }}" | sed -e 's/ /_/g' | sed -e 's/:/=/g')
425+
# Truncate to 215 chars to leave room for .tar.gz suffix and buffer
426+
tarball_name="test-results_${scenario_safe_name:0:215}.tar.gz"
427+
428+
if tar -czf "/tmp/${tarball_name}" -C /tmp/test-artifacts .; then
429+
{
430+
echo "tarball_created=true"
431+
echo "tarball_name=${tarball_name}"
432+
echo "tarball_path=/tmp/${tarball_name}"
433+
} | tee -a "$GITHUB_OUTPUT"
434+
435+
# Add artifact reference to step summary
436+
echo "" | tee -a "$GITHUB_STEP_SUMMARY"
437+
echo "Full test results available in artifact: \`${tarball_name}\`" | tee -a "$GITHUB_STEP_SUMMARY"
438+
else
439+
echo "::error::Failed to create tarball"
440+
echo "tarball_created=false" | tee -a "$GITHUB_OUTPUT"
441+
fi
420442
else
421-
echo "⚠️ No test results found in /tmp/vault_test_results_*.json" >> "$GITHUB_STEP_SUMMARY"
443+
echo "tarball_created=false" | tee -a "$GITHUB_OUTPUT"
422444
fi
423445
424-
- name: Upload Failure Summary
425-
if: always() && steps.check_test_results.outputs.has_results == 'true'
446+
- name: Upload test results tarball
447+
if: always() && steps.create_test_results_tarball.outputs.tarball_created == 'true'
448+
id: upload_test_results_tarball
426449
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
427450
with:
428-
name: ${{ steps.prepare_scenario.outputs.failure_summary_artifact_name }}
429-
path: ${{ steps.prepare_scenario.outputs.failure_summary_artifact_name }}
451+
name: ${{ steps.create_test_results_tarball.outputs.tarball_name }}
452+
path: ${{ steps.create_test_results_tarball.outputs.tarball_path }}
453+
retention-days: 7
430454
if-no-files-found: ignore
431455
continue-on-error: true
432456

0 commit comments

Comments
 (0)