|
9 | 9 | - **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). |
10 | 10 | - **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. |
11 | 11 |
|
| 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 | + |
12 | 17 | ## Execution Strategy |
13 | 18 | 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. |
18 | 25 |
|
19 | 26 | 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. |
25 | 33 |
|
26 | 34 | 3. **Reporting & Visualisation** |
27 | 35 | - Use GitHub Actions artefacts for report retrieval. |
|
35 | 43 | - Remove `continue-on-error` and make coverage generation mandatory. |
36 | 44 | - Introduce thresholds (e.g., fail if Rust line coverage < 70% or Python < 60%)—subject to discussion with the Runtime Tracing Team. |
37 | 45 |
|
| 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 | + |
38 | 53 | ## Risks & Mitigations |
39 | 54 | - **Runtime overhead:** Coverage runs are slower. Mitigate by limiting to a single matrix entry and caching `target/coverage` directories if needed. |
40 | 55 | - **Report size:** HTML artefacts can be large. Compress before upload and prune historical runs as necessary. |
|
45 | 60 | - Implement the local Just targets and update documentation. |
46 | 61 | - Extend CI workflow with optional coverage steps (post-tests) and artefact upload. |
47 | 62 | - Align with the developer experience team before enforcing thresholds. |
| 63 | + |
| 64 | +_Status tracking lives in `design-docs/test-suite-coverage-plan.status.md`._ |
0 commit comments