@@ -38,35 +38,11 @@ jobs:
3838 name : coverage-report
3939 path : coverage/jest-tests/
4040
41- - name : Coverage Summary
41+ - name : Jest Coverage Comment
42+ uses : MishaKav/jest-coverage-comment@main
4243 if : always()
43- run : |
44- echo "## π Jest Coverage Summary" >> $GITHUB_STEP_SUMMARY
45- echo "" >> $GITHUB_STEP_SUMMARY
46-
47- if [ -f coverage/jest-tests/coverage-summary.json ]; then
48- # Parse and display coverage metrics
49- echo "| Metric | Coverage | Threshold | Status |" >> $GITHUB_STEP_SUMMARY
50- echo "|--------|----------|-----------|--------|" >> $GITHUB_STEP_SUMMARY
51-
52- # Extract coverage percentages using grep and basic parsing
53- total_lines=$(cat coverage/jest-tests/coverage-summary.json | grep -o '"lines":{"total":[0-9]*,"covered":[0-9]*,"skipped":[0-9]*,"pct":[0-9.]*' | grep -o 'pct":[0-9.]*' | cut -d':' -f2)
54- total_statements=$(cat coverage/jest-tests/coverage-summary.json | grep -o '"statements":{"total":[0-9]*,"covered":[0-9]*,"skipped":[0-9]*,"pct":[0-9.]*' | grep -o 'pct":[0-9.]*' | cut -d':' -f2)
55- total_functions=$(cat coverage/jest-tests/coverage-summary.json | grep -o '"functions":{"total":[0-9]*,"covered":[0-9]*,"skipped":[0-9]*,"pct":[0-9.]*' | grep -o 'pct":[0-9.]*' | cut -d':' -f2)
56- total_branches=$(cat coverage/jest-tests/coverage-summary.json | grep -o '"branches":{"total":[0-9]*,"covered":[0-9]*,"skipped":[0-9]*,"pct":[0-9.]*' | grep -o 'pct":[0-9.]*' | cut -d':' -f2)
57-
58- # Check thresholds and add status
59- [ $(echo "$total_lines >= 40" | bc -l) -eq 1 ] && lines_status="β
" || lines_status="β"
60- [ $(echo "$total_statements >= 40" | bc -l) -eq 1 ] && stmt_status="β
" || stmt_status="β"
61- [ $(echo "$total_functions >= 100" | bc -l) -eq 1 ] && func_status="β
" || func_status="β"
62- [ $(echo "$total_branches >= 40" | bc -l) -eq 1 ] && branch_status="β
" || branch_status="β"
63-
64- echo "| Lines | ${total_lines}% | 40% | $lines_status |" >> $GITHUB_STEP_SUMMARY
65- echo "| Statements | ${total_statements}% | 40% | $stmt_status |" >> $GITHUB_STEP_SUMMARY
66- echo "| Functions | ${total_functions}% | 100% | $func_status |" >> $GITHUB_STEP_SUMMARY
67- echo "| Branches | ${total_branches}% | 40% | $branch_status |" >> $GITHUB_STEP_SUMMARY
68- echo "" >> $GITHUB_STEP_SUMMARY
69- echo "π Download the **coverage-report** artifact to view the detailed HTML coverage report." >> $GITHUB_STEP_SUMMARY
70- else
71- echo "β οΈ Coverage summary file not found." >> $GITHUB_STEP_SUMMARY
72- fi
44+ with :
45+ coverage-summary-path : coverage/jest-tests/coverage-summary.json
46+ title : Jest Coverage Report
47+ badge-title : Coverage
48+ create-new-comment : false
0 commit comments