diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a2a5025c..c6a921d0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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