|
| 1 | +name: 📣 Report Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["🧪 Run Tests"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + checks: write # For test reporting |
| 12 | + pull-requests: write # For PR comments |
| 13 | + |
| 14 | +jobs: |
| 15 | + report: |
| 16 | + name: Report Test Results |
| 17 | + runs-on: ubuntu-latest |
| 18 | + if: github.event.workflow_run.conclusion != 'cancelled' |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Download artifacts |
| 22 | + uses: actions/download-artifact@v4 |
| 23 | + with: |
| 24 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + run-id: ${{ github.event.workflow_run.id }} |
| 26 | + merge-multiple: true |
| 27 | + |
| 28 | + - name: Unit Test Report |
| 29 | + id: unit-test-report |
| 30 | + uses: dorny/test-reporter@v1 |
| 31 | + if: always() |
| 32 | + with: |
| 33 | + name: Unit Tests |
| 34 | + path: test-results.xml |
| 35 | + reporter: java-junit |
| 36 | + fail-on-error: false |
| 37 | + continue-on-error: true |
| 38 | + |
| 39 | + - name: API Test Report |
| 40 | + id: api-test-report |
| 41 | + uses: dorny/test-reporter@v1 |
| 42 | + if: always() |
| 43 | + with: |
| 44 | + name: API Contract Tests |
| 45 | + path: api-test-results.xml |
| 46 | + reporter: java-junit |
| 47 | + fail-on-error: false |
| 48 | + continue-on-error: true |
| 49 | + |
| 50 | + - name: E2E Test Report |
| 51 | + id: e2e-test-report |
| 52 | + uses: dorny/test-reporter@v1 |
| 53 | + if: always() |
| 54 | + with: |
| 55 | + name: E2E Tests |
| 56 | + path: e2e-results.xml |
| 57 | + reporter: java-junit |
| 58 | + fail-on-error: false |
| 59 | + continue-on-error: true |
| 60 | + |
| 61 | + - name: Generate detailed summary |
| 62 | + if: always() |
| 63 | + run: | |
| 64 | + # Read test results |
| 65 | + UNIT=$(cat test-result-unit.txt 2>/dev/null || echo "unknown") |
| 66 | + API=$(cat test-result-api.txt 2>/dev/null || echo "unknown") |
| 67 | + E2E=$(cat test-result-e2e.txt 2>/dev/null || echo "unknown") |
| 68 | +
|
| 69 | + # Helper functions |
| 70 | + em() { case "$1" in success) echo "✅";; failure) echo "❌";; cancelled|skipped) echo "⏭️";; *) echo "❔";; esac; } |
| 71 | + |
| 72 | + # Format time helper |
| 73 | + format_time() { |
| 74 | + local ms=$1 |
| 75 | + if [ "$ms" -gt 60000 ]; then |
| 76 | + echo "$((ms / 60000))m $((ms % 60000 / 1000))s" |
| 77 | + elif [ "$ms" -gt 1000 ]; then |
| 78 | + echo "$((ms / 1000))s" |
| 79 | + else |
| 80 | + echo "${ms}ms" |
| 81 | + fi |
| 82 | + } |
| 83 | +
|
| 84 | + # Get report data |
| 85 | + UNIT_PASSED="${{ steps.unit-test-report.outputs.passed || '0' }}" |
| 86 | + UNIT_FAILED="${{ steps.unit-test-report.outputs.failed || '0' }}" |
| 87 | + UNIT_SKIPPED="${{ steps.unit-test-report.outputs.skipped || '0' }}" |
| 88 | + UNIT_TIME="${{ steps.unit-test-report.outputs.time || '0' }}" |
| 89 | +
|
| 90 | + API_PASSED="${{ steps.api-test-report.outputs.passed || '0' }}" |
| 91 | + API_FAILED="${{ steps.api-test-report.outputs.failed || '0' }}" |
| 92 | + API_SKIPPED="${{ steps.api-test-report.outputs.skipped || '0' }}" |
| 93 | + API_TIME="${{ steps.api-test-report.outputs.time || '0' }}" |
| 94 | +
|
| 95 | + E2E_PASSED="${{ steps.e2e-test-report.outputs.passed || '0' }}" |
| 96 | + E2E_FAILED="${{ steps.e2e-test-report.outputs.failed || '0' }}" |
| 97 | + E2E_SKIPPED="${{ steps.e2e-test-report.outputs.skipped || '0' }}" |
| 98 | + E2E_TIME="${{ steps.e2e-test-report.outputs.time || '0' }}" |
| 99 | +
|
| 100 | + # Count failures |
| 101 | + failures=0 |
| 102 | + [ "$UNIT" = "failure" ] && failures=$((failures + 1)) |
| 103 | + [ "$API" = "failure" ] && failures=$((failures + 1)) |
| 104 | + [ "$E2E" = "failure" ] && failures=$((failures + 1)) |
| 105 | +
|
| 106 | + { |
| 107 | + echo "## 📊 Detailed Test Report" |
| 108 | + echo "" |
| 109 | + echo "**Overall Status:** $(em "${{ github.event.workflow_run.conclusion }}")" |
| 110 | + echo "" |
| 111 | +
|
| 112 | + if [ "$failures" -eq 0 ]; then |
| 113 | + echo "🎉 **All test suites passed!**" |
| 114 | + else |
| 115 | + echo "⚠️ **$failures test suite(s) failed**" |
| 116 | + fi |
| 117 | +
|
| 118 | + # Detailed Unit Test Report |
| 119 | + if [ "$UNIT_PASSED" != "0" ] || [ "$UNIT_FAILED" != "0" ] || [ "$UNIT_SKIPPED" != "0" ]; then |
| 120 | + echo "" |
| 121 | + echo "### $(em "$UNIT") Unit Test Details" |
| 122 | + echo "| Metric | Count |" |
| 123 | + echo "|--------|-------|" |
| 124 | + [ "$UNIT_PASSED" != "0" ] && echo "| ✅ Passed | $UNIT_PASSED |" |
| 125 | + [ "$UNIT_FAILED" != "0" ] && echo "| ❌ Failed | $UNIT_FAILED |" |
| 126 | + [ "$UNIT_SKIPPED" != "0" ] && echo "| ⏭️ Skipped | $UNIT_SKIPPED |" |
| 127 | + [ "$UNIT_TIME" != "0" ] && echo "| ⏱️ Duration | $(format_time $UNIT_TIME) |" |
| 128 | + fi |
| 129 | +
|
| 130 | + # Detailed API Test Report |
| 131 | + if [ "$API_PASSED" != "0" ] || [ "$API_FAILED" != "0" ] || [ "$API_SKIPPED" != "0" ]; then |
| 132 | + echo "" |
| 133 | + echo "### $(em "$API") API Contract Test Details" |
| 134 | + echo "| Metric | Count |" |
| 135 | + echo "|--------|-------|" |
| 136 | + [ "$API_PASSED" != "0" ] && echo "| ✅ Passed | $API_PASSED |" |
| 137 | + [ "$API_FAILED" != "0" ] && echo "| ❌ Failed | $API_FAILED |" |
| 138 | + [ "$API_SKIPPED" != "0" ] && echo "| ⏭️ Skipped | $API_SKIPPED |" |
| 139 | + [ "$API_TIME" != "0" ] && echo "| ⏱️ Duration | $(format_time $API_TIME) |" |
| 140 | + fi |
| 141 | +
|
| 142 | + # Detailed E2E Test Report |
| 143 | + if [ "$E2E_PASSED" != "0" ] || [ "$E2E_FAILED" != "0" ] || [ "$E2E_SKIPPED" != "0" ]; then |
| 144 | + echo "" |
| 145 | + echo "### $(em "$E2E") E2E Test Details" |
| 146 | + echo "| Metric | Count |" |
| 147 | + echo "|--------|-------|" |
| 148 | + [ "$E2E_PASSED" != "0" ] && echo "| ✅ Passed | $E2E_PASSED |" |
| 149 | + [ "$E2E_FAILED" != "0" ] && echo "| ❌ Failed | $E2E_FAILED |" |
| 150 | + [ "$E2E_SKIPPED" != "0" ] && echo "| ⏭️ Skipped | $E2E_SKIPPED |" |
| 151 | + [ "$E2E_TIME" != "0" ] && echo "| ⏱️ Duration | $(format_time $E2E_TIME) |" |
| 152 | + fi |
| 153 | +
|
| 154 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments