diff --git a/.github/workflows/unitTestPipeline.yaml b/.github/workflows/unitTestPipeline.yaml index 53fe4f9..0752f06 100644 --- a/.github/workflows/unitTestPipeline.yaml +++ b/.github/workflows/unitTestPipeline.yaml @@ -41,22 +41,22 @@ jobs: failures=0 errors=0 skipped=0 + duration=0 - for file in target/surefire-reports/*.txt; do + for file in target/surefire-reports/TEST-*.xml; do if [ -f "$file" ]; then - # Grab the FIRST "Tests run:" line only - line=$(grep -m1 "Tests run:" "$file") - if [ -n "$line" ]; then - t=$(echo "$line" | sed -E 's/.*Tests run: *([0-9]+).*/\1/') - f=$(echo "$line" | sed -E 's/.*Failures: *([0-9]+).*/\1/') - e=$(echo "$line" | sed -E 's/.*Errors: *([0-9]+).*/\1/') - s=$(echo "$line" | sed -E 's/.*Skipped: *([0-9]+).*/\1/') + t=$(grep -oP 'tests="\K[0-9]+' "$file" | head -1) + f=$(grep -oP 'failures="\K[0-9]+' "$file" | head -1) + e=$(grep -oP 'errors="\K[0-9]+' "$file" | head -1) + s=$(grep -oP 'skipped="\K[0-9]+' "$file" | head -1) + d=$(grep -oP 'time="\K[0-9]+(\.[0-9]+)?' "$file" | head -1) - total=$((total + t)) - failures=$((failures + f)) - errors=$((errors + e)) - skipped=$((skipped + s)) - fi + total=$((total + t)) + failures=$((failures + f)) + errors=$((errors + e)) + skipped=$((skipped + s)) + # use bc for float-safe addition + duration=$(echo "$duration + $d" | bc) fi done @@ -64,6 +64,8 @@ jobs: failed=$((failures + errors)) echo "summary=๐Ÿงช Total: $total | โœ… Passed: $passed | โŒ Failed: $failed" >> $GITHUB_OUTPUT + echo "duration=โฑ๏ธ Duration: ${duration}s" >> $GITHUB_OUTPUT + - name: Set Slack Color id: slack_color @@ -86,5 +88,6 @@ jobs: *๐Ÿ‘ค Triggered by:* `${{ github.actor }}` *๐ŸŒฟ Branch:* `${{ github.ref_name }}` *๐Ÿงช Test Summary:* `${{ steps.test_summary.outputs.summary }}` + *โฑ๏ธ Duration:* `${{ steps.test_summary.outputs.duration }}` *๐Ÿ“Š Full Report:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Open Report in Artifacts> SLACK_COLOR: ${{ steps.slack_color.outputs.color }} \ No newline at end of file