-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit.sh
executable file
·21 lines (17 loc) · 1.17 KB
/
pre-commit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
set -ex
ln -sf ../../pre-commit.sh .git/hooks/pre-commit
rustup component add llvm-tools-preview
cargo install cargo-binutils rustfilt cargo-audit grcov
export RUSTFLAGS="-D warnings -Z instrument-coverage"
cargo fmt -- --check
cargo clippy
# https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/instrument-coverage.html
binary=$(cargo test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]")
$binary
cargo profdata -- merge -sparse default.profraw -o default.profdata
cargo cov -- show --use-color --ignore-filename-regex='(/.cargo/registry)|(/rustc/)' --instr-profile=default.profdata --object $binary --show-instantiations --show-line-counts-or-regions --Xdemangler=rustfilt
cargo cov -- show --format=html --use-color --ignore-filename-regex='(/.cargo/registry)|(/rustc/)' --instr-profile=default.profdata --object $binary --output-dir=target/debug/coverage --show-instantiations --show-line-counts-or-regions --Xdemangler=rustfilt
firefox target/debug/coverage/index.html
cargo cov -- report --use-color --ignore-filename-regex='(/.cargo/registry)|(/rustc/)' --instr-profile=default.profdata --object $binary
cargo audit