Commit Graph

4 Commits

Author SHA1 Message Date
Fernando Lins
3f6378aee7 ci(coverage): fail PR if line coverage regresses (#4876)
## Linked issue

Closes #4874

## Summary / motivation

Adds `tools/coverage/check-coverage-regression.py` to compare line
coverage percentages from the current PR against the baseline saved from
main (introduced in #4875). If any stack regresses beyond the
configured tolerance (0.10%), the CI fails with a clear message showing
the delta.

Stacks checked: Rust, python-pylib, python-qt, TypeScript.

## How to test

Try to add some new code without any tests. The Ci must fail.

## Before / after behavior

Before: no signal when a PR reduces coverage below the current main
level.
After: CI fails on `Check coverage regression` with output like:
```
[rust] REGRESSION: 62.64% -> 61.00% (delta: -1.64%, tolerance: 0.10%)
1 stack(s) with coverage regression: rust
```
2026-05-25 13:46:57 -03:00
Abdo
1394540217 test: Add tests for build_installer.py (#4868)
## Linked issue

Closes #4859

## Summary

Add tests for the build_installer.py script with 100% coverage.

## How to test

Run `just test-py --coverage --html` and browse coverage data.
2026-05-21 07:10:27 +03:00
Fernando Lins
f9a5b36c82 feat: add TS test coverage (#4843)
## Linked issue

Closes #4840

## Summary / motivation

Adds Vitest V8 coverage for TypeScript/Svelte tests via
`@vitest/coverage-v8`.
Introduces `just test-ts --coverage` and `just test-ts --coverage
--html`,
and wires TypeScript into the `just test --coverage` umbrella —
completing
coverage support across all three stacks (Python, Rust, TypeScript).

The threshold is set to 5% — intentionally low because the Vitest test
count is small relative to the TypeScript/Svelte source surface. It is
meant to be raised as more tests are added.

## How to test

```sh
# Existing behavior unchanged
just test-ts

# Terminal summary + enforces 5% line coverage threshold
just test-ts --coverage

# Terminal summary + HTML report under out/coverage/typescript/
just test-ts --coverage --html

# Full umbrella — all three stacks
just test --coverage
just test --coverage --html
```

### Checklist

- [x] I ran `./ninja check` or an equivalent relevant check locally.

### Details

- `@vitest/coverage-v8` pinned at `3.2.4` in `package.json`.
- Reports are written to `out/coverage/typescript/` via
`--coverage.reportsDirectory=../out/coverage/typescript` (relative to
the `ts/` working directory where vitest runs).
- V8 provider is preferred over Istanbul: faster and requires no Babel
transform for TypeScript projects.
- Coverage measures only code reachable through Vitest's module graph —
Svelte component rendering is not covered.
- The `yarn` justfile variable is added for platform-aware yarn
invocation (Windows vs Unix).

## Before / after behavior

Before: no `just test-ts`, no TypeScript coverage.
After: `just test-ts` runs Vitest via ninja; `just test-ts --coverage`
runs with V8 instrumentation.
`just test --coverage` now spans all three stacks.

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2026-05-18 11:54:16 -03:00
Fernando Lins
f76fcec48f feat: add Rust test coverage (#4842)
## Linked issue

Closes #4839

## Summary / motivation

Adds `cargo-llvm-cov`-based test coverage for the full Rust workspace.
Introduces `just test-rust --coverage` and `just test-rust --coverage
--html`, and wires Rust into the `just test --coverage` umbrella.

`cargo-llvm-cov` is installed on demand into `out/bin/` to avoid
polluting the global cargo install. The `llvm-tools-preview` rustup
component is now installed in CI so the tool can instrument binaries.

## How to test (required)

```sh
# Existing behavior unchanged
just test-rust

# Terminal summary
just test-rust --coverage

# Terminal summary + HTML report under out/coverage/rust/html/
just test-rust --coverage --html

# Umbrella (Rust + Python)
just test --coverage
just test --coverage --html
```

Note: first run of `--coverage` will install `cargo-llvm-cov` into
`out/bin/` (~30s). Subsequent runs skip the install step.

### Checklist

- [x] I ran `./ninja check` or an equivalent relevant check locally.

### Details

- `cargo-llvm-cov` pinned at `0.8.4`, installed into `out/bin/` via
`cargo install --root out`.
- `--workspace --locked` measures all crates and respects the lockfile.
- `llvm-tools-preview` added to `setup-anki` action so CI can instrument
Rust binaries.
- Coverage runs are slower than plain `just test-rust` because
`cargo-llvm-cov` rebuilds with instrumentation — this is expected.

## Before / after behavior

Before: no `just test-rust`, no Rust coverage support.

After: `just test-rust` runs Rust tests via ninja; `just test-rust
--coverage` runs them with `cargo-llvm-cov`

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2026-05-18 11:38:37 -03:00