Skip to content
Open
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run tests
run: cargo test
- name: Install coverage tooling
run: cargo install cargo-llvm-cov --locked
- name: Enforce coverage threshold
env:
COVERAGE_THRESHOLD: 80
run: scripts/coverage.sh
- name: Fuzz test detection
run: |
if [ -d "contracts/utility_contracts/fuzz" ]; then
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ cd contracts && cargo build --target wasm32-unknown-unknown --release
# Test
cargo test

# Coverage (requires cargo-llvm-cov)
COVERAGE_THRESHOLD=80 scripts/coverage.sh

# Lint
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
Expand All @@ -115,7 +118,8 @@ The GitHub Actions workflow (`.github/workflows/ci.yml`) automatically runs on:
2. **Code Quality**: `cargo fmt --all -- --check` + `cargo clippy --target wasm32-unknown-unknown -- -D warnings`
3. **Build**: `cargo build --target wasm32-unknown-unknown --release`
4. **Unit Tests**: `cargo test` including fuzz tests
5. **Fuzz Tests**: Auto-detection and validation of fuzz infrastructure
5. **Coverage Gate**: `scripts/coverage.sh` enforces the configured line coverage threshold (`COVERAGE_THRESHOLD`, default 80%) for both the root package and contracts workspace
6. **Fuzz Tests**: Auto-detection and validation of fuzz infrastructure

### Local Development

Expand All @@ -124,6 +128,7 @@ cargo fmt --all -- --check
cargo clippy --target wasm32-unknown-unknown -- -D warnings
cargo build --target wasm32-unknown-unknown --release
cargo test
COVERAGE_THRESHOLD=80 scripts/coverage.sh
```

## ZK-SNARK Circuits for Sensor Privacy
Expand Down
20 changes: 20 additions & 0 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

COVERAGE_THRESHOLD="${COVERAGE_THRESHOLD:-80}"
CARGO_LLVM_COV_FLAGS=(--locked --all-features --workspace --fail-under-lines "${COVERAGE_THRESHOLD}")

if ! command -v cargo-llvm-cov >/dev/null 2>&1; then
echo "cargo-llvm-cov is required. Install it with: cargo install cargo-llvm-cov --locked"
exit 127
fi

echo "Enforcing line coverage threshold: ${COVERAGE_THRESHOLD}%"

echo "::group::Root package coverage"
cargo llvm-cov "${CARGO_LLVM_COV_FLAGS[@]}"
echo "::endgroup::"

echo "::group::Contracts workspace coverage"
cargo llvm-cov --manifest-path contracts/Cargo.toml "${CARGO_LLVM_COV_FLAGS[@]}"
echo "::endgroup::"