Skip to content

Commit 77ce564

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 77ce564

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,41 @@ 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+
# Format: "Chrome: |████| 7/7 test files | 182 passed, 0 failed"
53+
if grep -q "passed" test-output.log; then
54+
# Extract pass/fail counts from the progress line
55+
PASSED=$(grep -oP '\d+ passed' test-output.log | tail -1 | grep -oP '\d+' || echo "0")
56+
FAILED=$(grep -oP '\d+ failed' test-output.log | tail -1 | grep -oP '\d+' || echo "0")
57+
TOTAL=$((PASSED + FAILED))
58+
59+
if [ "$FAILED" = "0" ]; then
60+
echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
61+
else
62+
echo "❌ **Some tests failed**" >> $GITHUB_STEP_SUMMARY
63+
fi
64+
65+
echo "" >> $GITHUB_STEP_SUMMARY
66+
echo "| Metric | Count |" >> $GITHUB_STEP_SUMMARY
67+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
68+
echo "| Total Tests | $TOTAL |" >> $GITHUB_STEP_SUMMARY
69+
echo "| Passed | $PASSED |" >> $GITHUB_STEP_SUMMARY
70+
echo "| Failed | $FAILED |" >> $GITHUB_STEP_SUMMARY
71+
else
72+
echo "⚠️ Could not parse test results" >> $GITHUB_STEP_SUMMARY
73+
fi
74+
75+
exit $TEST_EXIT_CODE
4276
4377
- name: Upload coverage to Codecov
4478
uses: codecov/codecov-action@v4

0 commit comments

Comments
 (0)