CI Coverage Overview #103
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI Coverage Overview | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # Daily at 6 AM UTC | |
| workflow_dispatch: | |
| inputs: | |
| output_format: | |
| description: 'Output format' | |
| required: false | |
| default: 'markdown' | |
| type: choice | |
| options: | |
| - markdown | |
| - json | |
| jobs: | |
| summary: | |
| name: Summary | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Generate Summary Report | |
| run: | | |
| python scripts/ci/utils/ci_coverage_report.py --section summary | |
| by-folder: | |
| name: Tests by Folder | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Generate Tests by Folder Report | |
| run: | | |
| python scripts/ci/utils/ci_coverage_report.py --section by-folder | |
| by-suite: | |
| name: Tests by Suite | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Generate Tests by Suite Report | |
| run: | | |
| python scripts/ci/utils/ci_coverage_report.py --section by-suite | |
| unit-test-coverage: | |
| name: Unit Test Code Coverage | |
| runs-on: 1-gpu-h100 | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain + protoc | |
| # Editable install of sglang triggers `build_rust` for the bundled | |
| # native gRPC extension (rust/sglang-grpc). The 1-gpu-h100 runner | |
| # image has no Rust toolchain by default, which is why this job has | |
| # been failing on every scheduled run. Use the same helper that | |
| # ci_install_dependency.sh uses so the install path matches the | |
| # rest of CI. | |
| run: | | |
| bash scripts/ci/utils/install_rust_protoc.sh | |
| echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH | |
| - 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, reformatted | |
| awk '/^TOTAL / { for(i=1;i<=NF;i++) if($i~/^[0-9]+$/ || $i~/^[0-9]+%$/) a[++n]=$i; if(n>=3) printf "TOTAL Stmts: %s Miss: %s Cover: %s\n", a[1], a[2], a[3] }' coverage_output.txt >> $GITHUB_STEP_SUMMARY || true | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| # Core modules with coverage < 50%, sorted by uncovered lines (descending) | |
| LOW_COV=$(awk '/^python\/.*%/ { | |
| for (i=1; i<=NF; i++) { | |
| if ($i ~ /^[0-9]+%$/) { | |
| pct = $i + 0 | |
| if (pct >= 1 && pct < 50) { | |
| stmts = $(i-2) + 0 | |
| miss = $(i-1) + 0 | |
| printf "%d|%s|%d|%d|%d%%\n", miss, $1, stmts, miss, pct | |
| } | |
| break | |
| } | |
| } | |
| }' coverage_output.txt \ | |
| | grep -E '/(mem_cache|managers|sampling|parser|observability|function_call|entrypoints|speculative|multimodal|utils)/' \ | |
| | sort -t'|' -k1 -nr | cut -d'|' -f2- | head -40 || true) | |
| if [ -n "$LOW_COV" ]; then | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "<details><summary>Top uncovered core modules (coverage < 50%, sorted by uncovered lines)</summary>" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| File | Stmts | Miss | Cover |" >> $GITHUB_STEP_SUMMARY | |
| echo "|------|-------|------|-------|" >> $GITHUB_STEP_SUMMARY | |
| echo "$LOW_COV" | while IFS='|' read -r file stmts miss pct; do | |
| echo "| \`$file\` | $stmts | $miss | $pct |" >> $GITHUB_STEP_SUMMARY | |
| done | |
| echo "</details>" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| json-export: | |
| name: JSON Export | |
| runs-on: ubuntu-latest | |
| if: inputs.output_format == 'json' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Generate JSON Report | |
| run: | | |
| python scripts/ci/utils/ci_coverage_report.py --output-format json > ci_coverage.json | |
| - name: Upload JSON artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ci-coverage-report | |
| path: ci_coverage.json |