Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Code Coverage

on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]

env:
CARGO_TERM_COLOR: always

jobs:
coverage:
runs-on: ubuntu-latest
name: Generate Coverage Report
steps:
- uses: actions/checkout@v5

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Rust Cache
uses: Swatinem/rust-cache@v2

- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin

- name: Generate coverage report
run: |
cargo tarpaulin \
--workspace \
--out Xml \
--output-dir coverage \
--timeout 300 \
--exclude-files "tests/*" \
--ignore-panics

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/cobertura.xml
flags: rust
name: coverage-report
fail_ci_if_error: false
verbose: true

- name: Archive coverage report
if: always()
uses: actions/upload-artifact@v5
with:
name: coverage-report
path: coverage/
4 changes: 4 additions & 0 deletions .tarpaulin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[coverage]
timeout = 300
ignore-panics = true
exclude-files = ["tests/*", "benches/*"]
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
![WebARKitLib-rs](./assets/WebARKitLib-Rust-banner.jpg)

[![CI](https://github.com/webarkit/WebARKitLib-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/webarkit/WebARKitLib-rs/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/webarkit/WebARKitLib-rs/branch/main/graph/badge.svg)](https://codecov.io/gh/webarkit/WebARKitLib-rs)
[![Crates.io](https://img.shields.io/crates/v/webarkitlib-rs.svg)](https://crates.io/crates/webarkitlib-rs)
[![npm](https://img.shields.io/npm/v/@webarkit/webarkitlib-wasm.svg)](https://www.npmjs.com/package/@webarkit/webarkitlib-wasm)
[![GitHub stars](https://img.shields.io/github/stars/webarkit/WebARKitLib-rs.svg?style=social)](https://github.com/webarkit/WebARKitLib-rs/stargazers)
Expand Down Expand Up @@ -263,6 +264,36 @@ Because it's the `log` crate facade, any compatible backend works:

No library code change is needed — pick the backend in your application's entry point.

## 📈 Code Coverage

Coverage reports are generated automatically on every push and pull request via the [coverage workflow](.github/workflows/coverage.yml) using [cargo-tarpaulin](https://github.com/xd009642/tarpaulin) and uploaded to [Codecov](https://codecov.io/gh/webarkit/WebARKitLib-rs).

### Generate a Coverage Report Locally

```bash
# Install tarpaulin (once)
cargo install cargo-tarpaulin

# Run the helper script — produces coverage/index.html
./scripts/coverage.sh
```

Or run tarpaulin directly:

```bash
cargo tarpaulin --workspace --out Html --output-dir coverage --timeout 300
```

### Coverage Targets

| Area | Target |
|------|--------|
| Minimum overall | 75 % |
| Desirable overall | 85 %+ |
| Marker tracking (critical path) | 95 %+ |

---

## 📊 Benchmarking

We maintain a strict performance comparison with the original C library to ensure our Rust port remains competitive.
Expand Down
38 changes: 38 additions & 0 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# coverage.sh — Generate a local HTML code coverage report using cargo-tarpaulin.
#
# Usage:
# ./scripts/coverage.sh
#
# Requires cargo-tarpaulin to be installed:
# cargo install cargo-tarpaulin
set -e

echo "🧪 Generating Code Coverage Report..."
echo ""

# Clean previous coverage output
rm -rf coverage/
mkdir -p coverage/

echo "Using Tarpaulin for coverage..."
cargo tarpaulin \
--workspace \
--out Html \
--output-dir coverage \
--timeout 300 \
--exclude-files "tests/*" \
--ignore-panics \
--verbose

echo ""
echo "✅ Coverage report generated!"
echo ""
echo "📊 Open the report:"
if command -v open &> /dev/null; then
open coverage/index.html # macOS
elif command -v xdg-open &> /dev/null; then
xdg-open coverage/index.html # Linux
else
echo " $(pwd)/coverage/index.html"
fi
Loading