-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathcheck.sh
executable file
·117 lines (88 loc) · 2.51 KB
/
check.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
set -e
cd $(dirname "$0")
cd "$(git rev-parse --show-toplevel)"
source "tools/utils.sh"
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
function on_failure {
echo >&2
echo -e "${RED}Whoopsie-daisy: something failed!$NC" >&2
}
assert_installed "cargo"
trap on_failure ERR
function check_basic {
echo 'Building:'
cargo build --features fatal-warnings --all-targets
echo 'Testing:'
cargo test --features fatal-warnings --all-targets
# Weirdly, the `cargo test ... --all-targets ...` above does not run the tests in the documentation, so we run the
# doc tests like this.
# See https://github.com/rust-lang/cargo/issues/6669.
echo 'Testing doc:'
cargo test --features fatal-warnings --doc
echo 'Checking the benchmarks:'
cargo bench --features fatal-warnings -- --test
echo 'Checking documentation:'
cargo doc --features fatal-warnings --no-deps
# Tests for memory safety and memory leaks with miri.
if [ -z "$MIRI_TOOLCHAIN" ]; then
MIRI_TOOLCHAIN=nightly
fi
echo "Testing with miri (with toolchain $MIRI_TOOLCHAIN):"
cargo +$MIRI_TOOLCHAIN miri test --all-features
}
function check_doc_url_links {
assert_installed "cargo-deadlinks"
echo 'Checking doc url links:'
cargo deadlinks
}
function check_unused_deps {
assert_installed "cargo-machete"
echo 'Checking unused dependencies:'
cargo machete
}
function check_packaging {
echo 'Checking packaging:'
cargo package --allow-dirty
}
function check_fmt {
assert_installed "cargo-fmt"
echo 'Checking code format:'
cargo fmt -- --check
}
function check_toml_fmt {
assert_installed "taplo"
echo 'Checking toml format:'
taplo fmt --check
}
function check_readme {
assert_installed "cargo-rdme"
echo 'Checking readme:'
cargo rdme --check
}
function check_msrv {
assert_installed "cargo-msrv"
echo 'Checking the minimum supported rust version:'
cargo msrv verify
}
function check_clippy {
assert_installed "cargo-clippy"
echo 'Checking with clippy:'
cargo clippy --all-targets -- -D warnings
}
to_run=(basic doc_url_links unused_deps packaging fmt toml_fmt readme msrv clippy)
if [ $# -ge 1 ]; then
to_run=("$@")
fi
for check in "${to_run[@]}"; do
check_$check
done
echo
echo -e "${GREEN}Everything looks lovely!$NC"
exit 0