forked from feroxide/feroxide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
precommit.sh
executable file
·42 lines (30 loc) · 867 Bytes
/
precommit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
total_exit_code=0
export RUSTUP_NIGHTLY="yes"
CARGO="rustup run nightly cargo"
echo "Updating rust"
rustup update
total_exit_code=$((total_exit_code + $?))
echo "Updating Cargo.toml"
$CARGO update
total_exit_code=$((total_exit_code + $?))
echo "Formatting code"
$CARGO install rustfmt-nightly
$CARGO fmt
total_exit_code=$((total_exit_code + $?))
echo "Running clippy"
rustup component add clippy-preview
$CARGO clippy -- -D warnings
total_exit_code=$((total_exit_code + $?))
echo "Running tests"
$CARGO test
total_exit_code=$((total_exit_code + $?))
echo "Generating documentation"
./generate_docs.sh
total_exit_code=$((total_exit_code + $?))
if [ $total_exit_code -ne 0 ]; then
echo "One or more steps failed. Please read the logs" >&2
else
echo "All steps completed succesfully. You're now ready to commit!" >&2
fi
exit $total_exit_code