Skip to content

Add test coverage report and 95% target#59

Closed
clintjeff2 wants to merge 20 commits into
CalloraOrg:mainfrom
clintjeff2:main
Closed

Add test coverage report and 95% target#59
clintjeff2 wants to merge 20 commits into
CalloraOrg:mainfrom
clintjeff2:main

Conversation

@clintjeff2

Copy link
Copy Markdown
Contributor

chore: add test coverage report and 95% target

Summary

Implements issue #53 — adds cargo-tarpaulin based test coverage measurement
and enforces a minimum of 95 % line coverage on every push and pull-request.


Changes

New files

File Purpose
tarpaulin.toml cargo-tarpaulin configuration — fail-under = 95, HTML + XML + Stdout reports, lib = true to avoid Soroban cdylib linker issues
scripts/coverage.sh One-command local coverage runner; auto-installs cargo-tarpaulin if missing
.github/workflows/coverage.yml CI workflow: runs on push / PR, uploads HTML artefact, posts coverage table as a PR comment

Modified files

File Change
contracts/vault/src/test.rs Expanded from 2 to 8 tests — added cases for None initial balance, uninitialised vault, insufficient-balance guard, exact-balance deduction, and get_meta field validation
README.md New Test coverage section documents local and CI usage
.gitignore Added coverage/ to keep generated HTML / XML out of git

Coverage result

100 % line coverage (24 / 24 lines) — exceeds the 95 % minimum.
100 test coverage


How to reproduce locally

# One-time setup + run
./scripts/coverage.sh

# Or directly
cargo tarpaulin --config tarpaulin.toml

Open coverage/tarpaulin-report.html in a browser for the interactive report.


CI behaviour

  • cargo tarpaulin --config tarpaulin.toml runs on every push to main / master and on every PR.
  • The workflow exits non-zero (failing the required check) if coverage drops below 95 %.
  • The HTML report is uploaded as a downloadable workflow artefact (kept 30 days).
  • A summary table is posted as a comment on every pull-request.

Checklist

  • All 8 tests pass (cargo test)
  • Coverage ≥ 95 % verified locally (cargo tarpaulin)
  • tarpaulin.toml parses without warnings
  • scripts/coverage.sh is executable and self-contained
  • GitHub Actions workflow added
  • README updated with coverage section
  • coverage/ added to .gitignore
  • Screenshot of passing coverage run attached above

Closes #53

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

@clintjeff2 please resolve the conflicts

@clintjeff2

clintjeff2 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

@greatest0fallt1me
Please merge this ASAP, other contributors messed up the test files, had to redo everything all over again. And it was even more difficult.

Screenshot from 2026-02-24 11-57-12

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

@clintjeff2 resolve the conflicts

@clintjeff2 clintjeff2 closed this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Cargo Test Coverage Report to CI or Local Script

2 participants