Skip to content

Commit ec26710

Browse files
author
Dias, Diego
committed
Add comprehensive test reporting to GitHub Actions summary
- Add inline test results table to summary (passed/failed counts) - Add test parity comparison table showing mismatches - Generate HTML coverage reports for download - Parse and display coverage metrics in summary with threshold checks - Visual status indicators (✅/❌) for all metrics - Clear instructions to download HTML coverage report artifact
1 parent 7dad219 commit ec26710

File tree

3 files changed

+61
-8
lines changed

3 files changed

+61
-8
lines changed

.github/workflows/test-coverage.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,32 @@ jobs:
4141
- name: Coverage Summary
4242
if: always()
4343
run: |
44-
echo "## 📊 Coverage Summary" >> $GITHUB_STEP_SUMMARY
44+
echo "## 📊 Jest Coverage Summary" >> $GITHUB_STEP_SUMMARY
4545
echo "" >> $GITHUB_STEP_SUMMARY
46-
echo "Coverage report has been generated and uploaded as an artifact." >> $GITHUB_STEP_SUMMARY
47-
echo "" >> $GITHUB_STEP_SUMMARY
48-
echo "### Coverage Files" >> $GITHUB_STEP_SUMMARY
46+
4947
if [ -f coverage/jest-tests/coverage-summary.json ]; then
50-
echo '```json' >> $GITHUB_STEP_SUMMARY
51-
cat coverage/jest-tests/coverage-summary.json >> $GITHUB_STEP_SUMMARY
52-
echo '```' >> $GITHUB_STEP_SUMMARY
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
5372
fi

jest.config.jest-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
coveragePathIgnorePatterns: [
1111
"/node_modules/",
1212
],
13-
coverageReporters: ["text", "lcov", "json-summary"],
13+
coverageReporters: ["text", "lcov", "json-summary", "html"],
1414
coverageThreshold: {
1515
global: {
1616
branches: 40,

scripts/run-inline-tests.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,32 @@ echo "Passed: $PASSED"
5454
echo "Failed: $FAILED"
5555
echo ""
5656

57+
# Write to GitHub Actions Summary if available
58+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
59+
echo "## 🧪 Inline Assertion Tests" >> "$GITHUB_STEP_SUMMARY"
60+
echo "" >> "$GITHUB_STEP_SUMMARY"
61+
echo "| Metric | Count |" >> "$GITHUB_STEP_SUMMARY"
62+
echo "|--------|-------|" >> "$GITHUB_STEP_SUMMARY"
63+
echo "| Total Files | $TOTAL |" >> "$GITHUB_STEP_SUMMARY"
64+
echo "| ✅ Passed | $PASSED |" >> "$GITHUB_STEP_SUMMARY"
65+
echo "| ❌ Failed | $FAILED |" >> "$GITHUB_STEP_SUMMARY"
66+
echo "" >> "$GITHUB_STEP_SUMMARY"
67+
fi
68+
5769
# Now check test parity
5870
echo "=========================================="
5971
echo "🔍 Verifying Test Case Parity with Jest"
6072
echo "=========================================="
6173
echo ""
6274

75+
# Start parity table in GitHub summary if available
76+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
77+
echo "## 🔍 Test Case Parity Check" >> "$GITHUB_STEP_SUMMARY"
78+
echo "" >> "$GITHUB_STEP_SUMMARY"
79+
echo "| File | Inline | Jest | Status |" >> "$GITHUB_STEP_SUMMARY"
80+
echo "|------|--------|------|--------|" >> "$GITHUB_STEP_SUMMARY"
81+
fi
82+
6383
for impl_file in "$IMPLEMENT_DIR"/*.js; do
6484
filename=$(basename "$impl_file")
6585
base_name="${filename%.js}"
@@ -84,23 +104,37 @@ for impl_file in "$IMPLEMENT_DIR"/*.js; do
84104

85105
if [ "$inline_count" -eq "$jest_count" ]; then
86106
echo " ✅ Test counts match"
107+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
108+
echo "| $filename | $inline_count | $jest_count | ✅ Match |" >> "$GITHUB_STEP_SUMMARY"
109+
fi
87110
else
88111
echo " ⚠️ MISMATCH DETECTED"
89112
if [ $inline_count -gt $jest_count ]; then
90113
diff=$((inline_count - jest_count))
91114
echo " → Inline tests have $diff MORE assertion(s) than Jest"
92115
echo " → Jest tests may be missing $diff test case(s)"
116+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
117+
echo "| $filename | $inline_count | $jest_count | ⚠️ Inline +$diff |" >> "$GITHUB_STEP_SUMMARY"
118+
fi
93119
else
94120
diff=$((jest_count - inline_count))
95121
echo " → Jest tests have $diff MORE assertion(s) than Inline"
96122
echo " → Inline tests may be missing $diff test case(s)"
123+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
124+
echo "| $filename | $inline_count | $jest_count | ⚠️ Jest +$diff |" >> "$GITHUB_STEP_SUMMARY"
125+
fi
97126
fi
98127
PARITY_ISSUES=true
99128
fi
100129

101130
echo ""
102131
done
103132

133+
# Add summary note if in GitHub Actions
134+
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
135+
echo "" >> "$GITHUB_STEP_SUMMARY"
136+
fi
137+
104138
# Final summary
105139
echo "=========================================="
106140
echo "🎯 Final Summary"

0 commit comments

Comments
 (0)