Skip to content

tests: improve unit test coverage and set threshold #506

tests: improve unit test coverage and set threshold

tests: improve unit test coverage and set threshold #506

Workflow file for this run

on:
push:
branches:
- dev
pull_request:
branches:
- main
- dev
name: Unit Test
jobs:
unit_test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-test-
- name: Test with default features
run: cargo test --release
env:
RUST_BACKTRACE: 1
- name: Test for no_std
run: cargo test --release --no-default-features --features
embassy-rt,core,utils,wallet,models,helpers,websocket,json-rpc
env:
RUST_BACKTRACE: 1
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
# Integration-territory files (CLI, async network clients, sync wrappers
# around network calls, faucet) are excluded from unit-test coverage.
# They are exercised by tests under tests/ behind the `integration`
# feature flag, which run against a live rippled in a separate workflow.
# Mirrors xrpl-py's split between tests/unit/ (--fail-under=85) and
# tests/integration/ (--fail-under=70).
- name: Generate coverage report
run: |
cargo llvm-cov --lcov --output-path lcov.info \
--ignore-filename-regex 'src/(bin|cli|clients|account|ledger|asynch/clients|asynch/account|asynch/ledger|asynch/transaction|asynch/wallet)/|src/transaction/mod\.rs|src/wallet/faucet_generation\.rs'
- name: Check coverage thresholds
run: |
cargo llvm-cov --summary-only \
--ignore-filename-regex 'src/(bin|cli|clients|account|ledger|asynch/clients|asynch/account|asynch/ledger|asynch/transaction|asynch/wallet)/|src/transaction/mod\.rs|src/wallet/faucet_generation\.rs' \
--fail-under-lines 85 \
--fail-under-regions 85 \
--fail-under-functions 75
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: lcov-report
path: lcov.info