mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-05-30 11:44:23 +00:00
ci: fix frontend coverage reporting — debug output, handle empty FE_COVERAGE
This commit is contained in:
@@ -72,11 +72,27 @@ jobs:
|
||||
|
||||
# Generate frontend coverage report
|
||||
if [ -f .nyc_output/frontend-coverage.json ]; then
|
||||
FE_COVERAGE=$(npx nyc report --reporter=text-summary 2>&1 | grep 'Statements' | grep -oP '[\d.]+(?=%)')
|
||||
echo "{\"schemaVersion\":1,\"label\":\"frontend coverage\",\"message\":\"${FE_COVERAGE}%\",\"color\":\"$([ $(echo \"$FE_COVERAGE > 50\" | bc -l) -eq 1 ] && echo 'yellow' || echo 'red')\"}" > .badges/frontend-coverage.json
|
||||
echo "## Frontend Coverage" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Coverage: ${FE_COVERAGE}%" >> $GITHUB_STEP_SUMMARY
|
||||
npx nyc report --reporter=text-summary >> $GITHUB_STEP_SUMMARY 2>&1
|
||||
echo "Frontend coverage JSON found, generating report..."
|
||||
npx nyc report --reporter=text-summary --reporter=text 2>&1 | tee fe-report.txt
|
||||
FE_COVERAGE=$(grep 'Statements' fe-report.txt | head -1 | grep -oP '[\d.]+(?=%)' || echo "0")
|
||||
FE_COVERAGE=${FE_COVERAGE:-0}
|
||||
|
||||
if [ "$FE_COVERAGE" != "0" ] && [ $(echo "$FE_COVERAGE > 50" | bc -l 2>/dev/null || echo 0) -eq 1 ]; then
|
||||
FE_COLOR="yellow"
|
||||
elif [ "$FE_COVERAGE" != "0" ] && [ $(echo "$FE_COVERAGE > 80" | bc -l 2>/dev/null || echo 0) -eq 1 ]; then
|
||||
FE_COLOR="brightgreen"
|
||||
else
|
||||
FE_COLOR="red"
|
||||
fi
|
||||
echo "{\"schemaVersion\":1,\"label\":\"frontend coverage\",\"message\":\"${FE_COVERAGE}%\",\"color\":\"${FE_COLOR}\"}" > .badges/frontend-coverage.json
|
||||
|
||||
echo "## Frontend Coverage: ${FE_COVERAGE}%" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
cat fe-report.txt >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "WARNING: No frontend coverage JSON found"
|
||||
echo "{\"schemaVersion\":1,\"label\":\"frontend coverage\",\"message\":\"N/A\",\"color\":\"gray\"}" > .badges/frontend-coverage.json
|
||||
fi
|
||||
|
||||
echo "{\"schemaVersion\":1,\"label\":\"frontend tests\",\"message\":\"${E2E_PASS:-0} E2E passed\",\"color\":\"brightgreen\"}" > .badges/frontend-tests.json
|
||||
|
||||
Reference in New Issue
Block a user