version: '3'
vars:
coverage_rust_flags: '-C instrument-coverage'
coverage_path: ./target/debug/coverage
coverage_llvm_file: '{{.coverage_path}}/profile/app-%p-%m.profraw'
tasks:
fix:
desc: Format code, apply cargo fix and run clippy
cmds:
- cargo fmt
- cargo fix --allow-dirty --allow-staged
- cargo clippy -- -W clippy::pedantic -W clippy::nursery -W clippy::unwrap_used -W clippy::panic -W clippy::missing_panics_doc -W clippy::panic_in_result_fn -W clippy::cargo_common_metadata
test:
desc: Run tests
cmds:
- cargo test
coverage:
desc: Build and test with coverage instrumentation and generate HTML report via grcov
cmds:
- rm -rf {{.coverage_path}}
- mkdir -p {{.coverage_path}}
- RUSTFLAGS="{{.coverage_rust_flags}}" LLVM_PROFILE_FILE="{{.coverage_llvm_file}}" cargo build
- RUSTFLAGS="{{.coverage_rust_flags}}" LLVM_PROFILE_FILE="{{.coverage_llvm_file}}" cargo test
- LLVM_PROFILE_FILE="{{.coverage_llvm_file}}" grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o {{.coverage_path}} --excl-line "#\[derive"
- cat {{.coverage_path}}/html/coverage.json | jq
- rm -rf {{.coverage_path}}/profile/