diff --git a/.github/workflows/ci-coverage-overview.yml b/.github/workflows/ci-coverage-overview.yml index db9269d67..d05eae40a 100644 --- a/.github/workflows/ci-coverage-overview.yml +++ b/.github/workflows/ci-coverage-overview.yml @@ -68,6 +68,68 @@ jobs: run: | python scripts/ci/utils/ci_coverage_report.py --section by-suite + unit-test-coverage: + name: Unit Test Code Coverage + if: github.event_name != 'pull_request' + runs-on: 1-gpu-runner + timeout-minutes: 30 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + timeout-minutes: 10 + run: | + pip install -e "python/[test]" + + - name: Run unit tests with coverage + timeout-minutes: 10 + run: | + pytest test/registered/unit/ \ + --cov --cov-config=.coveragerc \ + --cov-report=term-missing:skip-covered \ + --continue-on-collection-errors \ + -v | tee coverage_output.txt + + - name: Write coverage to summary + if: always() + run: | + echo "## Unit Test Code Coverage" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Commit:** \`${GITHUB_SHA::8}\` | **Branch:** \`${GITHUB_REF_NAME}\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + # Test result line (e.g., "== 42 passed, 1 failed in 23.5s ==") + echo '```' >> $GITHUB_STEP_SUMMARY + grep -E '^=+.*passed' coverage_output.txt >> $GITHUB_STEP_SUMMARY || true + echo "" >> $GITHUB_STEP_SUMMARY + # Coverage total + grep -E '^TOTAL ' coverage_output.txt >> $GITHUB_STEP_SUMMARY || true + echo '```' >> $GITHUB_STEP_SUMMARY + + # Partially covered core modules (1-49%) — most actionable for contributors + # Only show modules with testable logic; skip configs, models, layers, etc. + LOW_COV=$(awk '/^python\/.*%/ { + for (i=1; i<=NF; i++) { + if ($i ~ /^[0-9]+%$/) { + pct = $i + 0 + if (pct >= 1 && pct < 50) printf "%-80s %5s %s\n", $1, $(i-2), $i + break + } + } + }' coverage_output.txt \ + | grep -E '/(mem_cache|managers|sampling|parser|observability|function_call|entrypoints|speculative|multimodal|utils)/' \ + | head -40 || true) + if [ -n "$LOW_COV" ]; then + echo "" >> $GITHUB_STEP_SUMMARY + echo "
Core modules with coverage below 50% — good candidates for more unit tests" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "$LOW_COV" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY + fi + json-export: name: JSON Export runs-on: ubuntu-latest