@@ -41,29 +41,31 @@ jobs:
4141 failures=0
4242 errors=0
4343 skipped=0
44+ duration=0
4445
45- for file in target/surefire-reports/*.txt ; do
46+ for file in target/surefire-reports/TEST-*.xml ; do
4647 if [ -f "$file" ]; then
47- # Grab the FIRST "Tests run:" line only
48- line=$(grep -m1 "Tests run:" "$file")
49- if [ -n "$line" ]; then
50- t=$(echo "$line" | sed -E 's/.*Tests run: *([0-9]+).*/\1/')
51- f=$(echo "$line" | sed -E 's/.*Failures: *([0-9]+).*/\1/')
52- e=$(echo "$line" | sed -E 's/.*Errors: *([0-9]+).*/\1/')
53- s=$(echo "$line" | sed -E 's/.*Skipped: *([0-9]+).*/\1/')
48+ t=$(grep -oP 'tests="\K[0-9]+' "$file" | head -1)
49+ f=$(grep -oP 'failures="\K[0-9]+' "$file" | head -1)
50+ e=$(grep -oP 'errors="\K[0-9]+' "$file" | head -1)
51+ s=$(grep -oP 'skipped="\K[0-9]+' "$file" | head -1)
52+ d=$(grep -oP 'time="\K[0-9]+(\.[0-9]+)?' "$file" | head -1)
5453
55- total=$((total + t))
56- failures=$((failures + f))
57- errors=$((errors + e))
58- skipped=$((skipped + s))
59- fi
54+ total=$((total + t))
55+ failures=$((failures + f))
56+ errors=$((errors + e))
57+ skipped=$((skipped + s))
58+ # use bc for float-safe addition
59+ duration=$(echo "$duration + $d" | bc)
6060 fi
6161 done
6262
6363 passed=$((total - failures - errors - skipped))
6464 failed=$((failures + errors))
6565
6666 echo "summary=🧪 Total: $total | ✅ Passed: $passed | ❌ Failed: $failed" >> $GITHUB_OUTPUT
67+ echo "duration=⏱️ Duration: ${duration}s" >> $GITHUB_OUTPUT
68+
6769
6870 - name : Set Slack Color
6971 id : slack_color
8688 *👤 Triggered by:* `${{ github.actor }}`
8789 *🌿 Branch:* `${{ github.ref_name }}`
8890 *🧪 Test Summary:* `${{ steps.test_summary.outputs.summary }}`
91+ *⏱️ Duration:* `${{ steps.test_summary.outputs.duration }}`
8992 *📊 Full Report:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Open Report in Artifacts>
9093 SLACK_COLOR : ${{ steps.slack_color.outputs.color }}
0 commit comments