-
Notifications
You must be signed in to change notification settings - Fork 0
/
develop.sh
executable file
·115 lines (104 loc) · 3.22 KB
/
develop.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
#!/bin/bash
set -eo pipefail
current_path="$(realpath $0)"
current_dir="$(dirname $current_path)"
function format() {
cargo fmt
find ./ -iname *.proto | xargs clang-format -style=Google -i
}
function lint() {
cargo fmt --all -- --check
disallow=(
warnings
unsafe_code
trivial_casts
trivial_numeric_casts
# unreachable_pub
# missing_docs
unused_extern_crates
unused_import_braces
unused_qualifications
clippy::clone_on_ref_ptr
clippy::all
clippy::correctness
clippy::suspicious
clippy::complexity
clippy::perf
clippy::style
clippy::pedantic
# clippy::nursery
# clippy::missing_errors_doc
# clippy::missing_panics_doc
)
allow=(
unused_braces
clippy::module_name_repetitions
clippy::cast_possible_truncation
clippy::cast_possible_wrap
clippy::must_use_candidate
clippy::cast_sign_loss
clippy::too_many_lines
clippy::needless_pass_by_value
clippy::struct_excessive_bools
clippy::missing_errors_doc
clippy::missing_panics_doc
clippy::struct_field_names
)
cargo clippy --workspace --all-targets --all-features \
-- ${disallow[@]/#/-D } ${allow[@]/#/-A }
cargo clippy --workspace --target wasm32-unknown-unknown \
--features wasm,derive,prost,proto,request,serde,chrono \
-- ${disallow[@]/#/-D } ${allow[@]/#/-A }
}
function test() {
if [[ "$2" =~ ^(--no-default-features)$ ]]; then
cargo test --workspace --all-targets --no-default-features --features testing,request -- --nocapture
cargo test --workspace --doc --no-default-features --features testing -- --nocapture
else
cargo test --workspace --all-targets --all-features -- --nocapture
cargo test --workspace --doc --all-features -- --nocapture
fi
}
function publish() {
if [[ "$2" =~ ^(--actually-do-it)$ ]]; then
cargo publish -p bomboni_core --allow-dirty
cargo publish -p bomboni_wasm_core --allow-dirty
cargo publish -p bomboni_wasm_derive --allow-dirty
cargo publish -p bomboni_wasm --allow-dirty
cargo publish -p bomboni_common --allow-dirty
cargo publish -p bomboni_prost --allow-dirty
cargo publish -p bomboni_proto --allow-dirty
cargo publish -p bomboni_request_derive --allow-dirty
cargo publish -p bomboni_request --allow-dirty
cargo publish -p bomboni_template --allow-dirty
cargo publish -p bomboni_fs --allow-dirty
cargo publish -p bomboni --allow-dirty
else
cargo publish -p bomboni_core --allow-dirty --dry-run
cargo publish -p bomboni_wasm_core --allow-dirty --dry-run
cargo publish -p bomboni_wasm_derive --allow-dirty --dry-run
cargo publish -p bomboni_common --allow-dirty --dry-run
cargo publish -p bomboni_wasm --allow-dirty --dry-run
cargo publish -p bomboni_prost --allow-dirty --dry-run
cargo publish -p bomboni_proto --allow-dirty --dry-run
cargo publish -p bomboni_request_derive --allow-dirty --dry-run
cargo publish -p bomboni_request --allow-dirty --dry-run
cargo publish -p bomboni_template --allow-dirty --dry-run
cargo publish -p bomboni_fs --allow-dirty --dry-run
cargo publish -p bomboni --allow-dirty --dry-run
fi
}
function help() {
echo "Usage: $(basename "$0") [OPTIONS]
Commands:
lint Run lints
test Run all tests
help Show help
"
}
if [[ $1 =~ ^(format|lint|test|publish|help)$ ]]; then
"$@"
else
help
exit 1
fi