Skip to content

Commit bcd0c76

Browse files
committed
feat(ci): Add native test result summaries
Enhances CI workflow with automated reporting for better visibility: **Native Test Result Summaries:** - Adds GitHub job summary showing test pass/fail status - Displays formatted table with total/passed/failed test counts - Uses only native GitHub features ($GITHUB_STEP_SUMMARY) - No third-party actions required for test reporting **Benefits:** - Test results summary on workflow run page - Maintains existing artifact upload for manual inspection - All reporting uses native or org-approved tools
1 parent 9597dfa commit bcd0c76

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,39 @@ jobs:
3838
run: npm ci
3939

4040
- name: Run tests with coverage
41-
run: npm run test:coverage
41+
run: |
42+
npm run test:coverage 2>&1 | tee test-output.log
43+
echo "TEST_EXIT_CODE=${PIPESTATUS[0]}" >> $GITHUB_ENV
44+
45+
- name: Generate test summary
46+
if: always()
47+
run: |
48+
echo "### Test Results 📊" >> $GITHUB_STEP_SUMMARY
49+
echo "" >> $GITHUB_STEP_SUMMARY
50+
51+
# Extract test results from web-test-runner output
52+
if grep -q "Finished running tests" test-output.log; then
53+
# Extract pass/fail counts
54+
TOTAL=$(grep -oP "Finished running tests.*?(\d+) passed" test-output.log | grep -oP "\d+" | head -1 || echo "0")
55+
FAILED=$(grep -oP "(\d+) failed" test-output.log | grep -oP "\d+" | head -1 || echo "0")
56+
57+
if [ "$FAILED" = "0" ]; then
58+
echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
59+
else
60+
echo "❌ **Some tests failed**" >> $GITHUB_STEP_SUMMARY
61+
fi
62+
63+
echo "" >> $GITHUB_STEP_SUMMARY
64+
echo "| Metric | Count |" >> $GITHUB_STEP_SUMMARY
65+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
66+
echo "| Total Tests | $TOTAL |" >> $GITHUB_STEP_SUMMARY
67+
echo "| Failed | $FAILED |" >> $GITHUB_STEP_SUMMARY
68+
echo "| Passed | $((TOTAL - FAILED)) |" >> $GITHUB_STEP_SUMMARY
69+
else
70+
echo "⚠️ Could not parse test results" >> $GITHUB_STEP_SUMMARY
71+
fi
72+
73+
exit $TEST_EXIT_CODE
4274
4375
- name: Upload coverage to Codecov
4476
uses: codecov/codecov-action@v4

0 commit comments

Comments
 (0)