ci(sight): add unit test coverage gate for agentsight#840
Open
jfeng18 wants to merge 3 commits into
Open
Conversation
Add cargo-llvm-cov coverage measurement and diff-cover incremental gate (80% on new/changed lines) to the test-agentsight CI job. - Replace bare `cargo test` with `cargo llvm-cov --cobertura` - Exclude BPF probes and generated code from coverage measurement - Upload Cobertura XML as CI artifact (30 days) - Show coverage summary in GitHub Step Summary - Enforce 80% incremental coverage on PRs via diff-cover - Show uncovered files in collapsible details on gate failure - Add Makefile targets: test, test-coverage, coverage - Document CI quality gates and local reproduction in DEVELOPMENT.md Closes alibaba#836 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
libbpf-cargo SkeletonBuilder requires rustfmt to format generated .skel.rs files. The previous commit removed it from components, causing build.rs to fail with "rustfmt is not installed". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace grep -oP + bc with Python xml.etree for parsing the Cobertura coverage report. More robust across runner environments. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #836
cargo-llvm-covcoverage measurement to thetest-agentsightCI jobdiff-cover(new/changed lines must have ≥ 80% test coverage)src/probes/) and generated files (.skel.rs, bindgen output) excluded from coverage measurementtest,test-coverage,coverage) for local developmentDEVELOPMENT.mdDesign decisions
Incremental gate (not overall threshold): Current overall coverage is ~48%. A hard 80% overall gate would block all CI runs. The incremental gate ensures all new code meets 80%, and overall coverage ratchets up organically as new code is added with tests.
No fmt/clippy gates in this PR: The codebase has pre-existing fmt (1107 diffs) and clippy (43 errors) issues. Adding those gates requires separate cleanup PRs to avoid scope explosion. This PR focuses solely on coverage measurement.
cargo-llvm-cov over tarpaulin: cargo-llvm-cov uses LLVM source-based instrumentation (no ptrace), avoiding conflicts with libbpf-rs BPF syscalls. Already used by agent-sec-core in the same CI file.
Acceptance criteria checklist
THRESHOLD=80variable in CI step)DEVELOPMENT.md)Verification
cargo-llvm-cov --coberturatested locally — produces valid Cobertura XML (47.6%, 12233/25683 lines)diff-covertested locally — correctly consumes the XML, grep parsing verifiedyaml.safe_load()Test plan
🤖 Generated with Claude Code