Skip to content

Commit aff22e4

Browse files
committed
Coverage reports
1 parent 606c458 commit aff22e4

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

design-docs/test-suite-coverage-plan.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,27 @@
99
- **Rust:** Use `cargo llvm-cov` to aggregate unit and integration test coverage. This tool integrates with `nextest` and produces both lcov and HTML outputs. It works with the existing `nix develop` environment once `llvm-tools-preview` is available (already pulled by rustup in Nix environment).
1010
- **Python:** Use `pytest --cov` with the `coverage` plugin. Restrict collection to the `codetracer_python_recorder` package to avoid noise from site-packages. Generate both terminal summaries and Cobertura XML for upload.
1111

12+
## Prerequisites & Dependencies
13+
- Add `cargo-llvm-cov` to the dev environment so the Just targets and CI runners share the same binary. In the Nix shell, include the package and ensure the Rust toolchain exposes `llvm-tools-preview`.
14+
- Extend the UV `dev` dependency group with `pytest-cov` and `coverage[toml]` so Python coverage instrumentation is reproducible locally and in CI.
15+
- Standardise coverage outputs under `codetracer-python-recorder/target/coverage` to keep artefacts inside the Rust crate. Use `target/coverage/{rust,python}` for per-language assets and a top-level `index.txt` to note the run metadata if needed later.
16+
1217
## Execution Strategy
1318
1. **Local Workflow**
14-
- Add convenience Just targets:
15-
- `just coverage-rust``uv run cargo llvm-cov --no-default-features --lcov --output-path target/coverage/rust.lcov` (also emit HTML under `target/coverage/html`).
16-
- `just coverage-python``uv run --group dev --group test pytest --cov=codetracer_python_recorder --cov-report=term --cov-report=xml:target/coverage/python.xml tests/python`.
17-
- Document usage in `tests/README.md` so developers can opt-in.
19+
- Add convenience Just targets that mirror the default test steps:
20+
- `just coverage-rust``uv run cargo llvm-cov --manifest-path codetracer-python-recorder/Cargo.toml --no-default-features --nextest --lcov --output-path codetracer-python-recorder/target/coverage/rust/lcov.info --html codetracer-python-recorder/target/coverage/rust/html`.
21+
- `just coverage-python``uv run --group dev --group test pytest --cov=codetracer_python_recorder --cov-report=term --cov-report=xml:codetracer-python-recorder/target/coverage/python/coverage.xml codetracer-python-recorder/tests/python`.
22+
- `just coverage` wrapper → runs the Rust step followed by the Python step so developers get both artefacts with one command, matching the eventual CI flow.
23+
- Ensure the commands create their output directories (`target/coverage/rust` and `target/coverage/python`) before writing results to avoid failures on first use.
24+
- Document the workflow in `codetracer-python-recorder/tests/README.md` (and reference the top-level `README` if needed) so contributors know when to run the coverage helpers versus the regular test splits.
1825

1926
2. **CI Integration (non-blocking first pass)**
20-
- Extend `.github/workflows/ci.yml` with optional coverage steps that run after the primary test steps on one Python version (e.g., 3.12) to limit runtime.
21-
- Upload artefacts:
22-
- Rust: `rust-coverage.lcov` + zipped HTML report.
23-
- Python: `python-coverage.xml` + terminal summary (already in logs).
24-
- Mark coverage steps as `continue-on-error: true` initially so transient issues don’t fail the pipeline.
27+
- Extend `.github/workflows/ci.yml` with optional `coverage-rust` and `coverage-python` jobs that depend on the primary test jobs and only run when `matrix.python-version == '3.12'` and `matrix.os == 'ubuntu-latest'` to avoid duplicate collection.
28+
- Reuse the Just targets so CI mirrors local behaviour. Inject `RUSTFLAGS`/`RUSTDOCFLAGS` from the test jobs’ cache to avoid rebuilding dependencies.
29+
- Publish artefacts via `actions/upload-artifact`:
30+
- Rust: `codetracer-python-recorder/target/coverage/rust/lcov.info` plus a gzipped archive of the HTML folder.
31+
- Python: `codetracer-python-recorder/target/coverage/python/coverage.xml` for future parsing.
32+
- Mark coverage steps with `continue-on-error: true` during the stabilisation phase and note the run IDs in the job summary for quick retrieval.
2533

2634
3. **Reporting & Visualisation**
2735
- Use GitHub Actions artefacts for report retrieval.
@@ -35,6 +43,13 @@
3543
- Remove `continue-on-error` and make coverage generation mandatory.
3644
- Introduce thresholds (e.g., fail if Rust line coverage < 70% or Python < 60%)—subject to discussion with the Runtime Tracing Team.
3745

46+
## Implementation Checklist
47+
- [ ] Update development environment dependencies (`flake.nix`, `pyproject.toml`) to support coverage tooling out of the box.
48+
- [ ] Add `just coverage-rust`, `just coverage-python`, and `just coverage` helpers with directory bootstrapping.
49+
- [ ] Refresh documentation (`codetracer-python-recorder/tests/README.md` and top-level testing guide) with coverage instructions.
50+
- [ ] Extend CI workflow with non-blocking coverage jobs and artefact upload.
51+
- [ ] Review initial coverage artefacts to set baseline thresholds before enforcement.
52+
3853
## Risks & Mitigations
3954
- **Runtime overhead:** Coverage runs are slower. Mitigate by limiting to a single matrix entry and caching `target/coverage` directories if needed.
4055
- **Report size:** HTML artefacts can be large. Compress before upload and prune historical runs as necessary.
@@ -45,3 +60,5 @@
4560
- Implement the local Just targets and update documentation.
4661
- Extend CI workflow with optional coverage steps (post-tests) and artefact upload.
4762
- Align with the developer experience team before enforcing thresholds.
63+
64+
_Status tracking lives in `design-docs/test-suite-coverage-plan.status.md`._
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Test Suite Coverage Plan Status
2+
3+
## Current Status
4+
- ✅ Plan doc expanded with prerequisites, detailed Just targets, CI strategy, and an implementation checklist (see `design-docs/test-suite-coverage-plan.md`).
5+
- 🚧 Implementation: add coverage tooling dependencies to the dev shell and UV groups so local + CI runners share the same setup.
6+
- ⏳ Implementation: land `just coverage-*` helpers and update developer documentation.
7+
- ⏳ Implementation: wire optional coverage jobs into `.github/workflows/ci.yml` with artefact uploads.
8+
- ⏳ Assessment: capture baseline coverage numbers before proposing enforcement thresholds.
9+
10+
## Next Steps
11+
1. Update environment dependencies for coverage (`cargo-llvm-cov`, `pytest-cov`, `coverage[toml]`).
12+
2. Introduce the Just coverage commands and document how to use them.
13+
3. Extend CI with non-blocking coverage collection and review the initial artefacts.

0 commit comments

Comments
 (0)