forked from duesee/imap-codec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
230 lines (196 loc) · 6.35 KB
/
justfile
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
export RUSTFLAGS := "-D warnings"
export RUSTDOCFLAGS := "-D warnings"
[private]
default:
just -l --unsorted
###########
### RUN ###
###########
# Run (local) CI
ci: (ci_impl "" "" ) \
(ci_impl "" " --all-features") \
(ci_impl " --release" "" ) \
(ci_impl " --release" " --all-features")
[private]
ci_impl mode features: (check_impl mode features) (test_impl mode features)
# Check syntax, formatting, clippy, deny, semver, ...
check: (check_impl "" "" ) \
(check_impl "" " --all-features") \
(check_impl " --release" "" ) \
(check_impl " --release" " --all-features")
[private]
check_impl mode features: (cargo_check mode features) \
(cargo_hack mode) \
cargo_fmt \
(cargo_clippy mode features) \
cargo_deny \
cargo_semver
[private]
cargo_check mode features:
cargo check --workspace --all-targets{{ mode }}{{ features }}
cargo doc --no-deps --document-private-items --keep-going{{ mode }}{{ features }}
[private]
cargo_hack mode: install_cargo_hack
cargo hack check --workspace --all-targets{{ mode }}
cargo hack check -p imap-codec \
--no-dev-deps \
--exclude-features default \
--feature-powerset \
--group-features \
starttls,\
ext_condstore_qresync,\
ext_login_referrals,\
ext_mailbox_referrals,\
ext_id,\
ext_sort_thread,\
ext_binary,\
ext_metadata \
--group-features \
quirk_crlf_relaxed,\
quirk_rectify_numbers,\
quirk_missing_text,\
quirk_id_empty_to_nil,\
quirk_trailing_space\
{{ mode }}
cargo hack check -p imap-types \
--no-dev-deps \
--feature-powerset \
--group-features \
arbitrary,\
arbitrary_simplified,\
bounded-static,\
serde \
--group-features \
starttls,\
ext_condstore_qresync,\
ext_login_referrals,\
ext_mailbox_referrals,\
ext_id,\
ext_sort_thread,\
ext_binary,\
ext_metadata\
{{ mode }}
[private]
cargo_fmt: install_rust_nightly install_rust_nightly_fmt
cargo +nightly fmt --check
[private]
cargo_clippy features mode: install_cargo_clippy
cargo clippy --workspace --all-targets{{ features }}{{ mode }}
[private]
cargo_deny: install_cargo_deny
cargo deny check
[private]
cargo_semver: install_cargo_semver_checks
cargo semver-checks check-release --only-explicit-features -p imap-codec
cargo semver-checks check-release --only-explicit-features -p imap-types
# Test multiple configurations
test: (test_impl "" "" ) \
(test_impl "" " --all-features") \
(test_impl " --release" "" ) \
(test_impl " --release" " --all-features")
[private]
test_impl mode features: (cargo_test mode features)
[private]
cargo_test features mode:
cargo test \
--workspace \
--exclude imap-types-fuzz \
--exclude imap-codec-fuzz \
--all-targets\
{{ features }}\
{{ mode }}
# Audit advisories, bans, licenses, and sources
audit: cargo_deny
# Benchmark
bench:
cargo bench -p imap-codec --all-features bench_command_parse_simple
# Benchmark against main
bench_against_main:
rm -rf target/bench_tmp
mkdir -p target/bench_tmp
git clone --depth 1 https://github.com/duesee/imap-codec target/bench_tmp
cd target/bench_tmp; cargo bench -p imap-codec --all-features
rm -rf target/criterion
cp -r target/bench_tmp/target/criterion target/criterion
cargo bench -p imap-codec --all-features
rm -rf target/bench_tmp
# Measure test coverage
coverage: install_rust_llvm_tools_preview install_cargo_grcov
mkdir -p target/coverage
RUSTFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE="coverage-%m-%p.profraw" cargo test -p imap-codec -p imap-types --all-features
grcov . \
--source-dir . \
--binary-path target/debug \
--branch \
--keep-only '{imap-codec/src/**,imap-types/src/**}' \
--output-types "lcov" \
--llvm > target/coverage/coverage.lcov
# TODO: Create files in `target/coverage` only.
rm *.profraw
rm imap-types/*.profraw
rm imap-codec/*.profraw
# Fuzz all targets
[linux]
fuzz runs="25000": install_cargo_fuzz
#!/usr/bin/env bash
set -euo pipefail
cd imap-codec
for fuzz_target in $(cargo +nightly fuzz list)
do
echo "# Fuzzing ${fuzz_target}";
cargo +nightly fuzz run --features=ext,arbitrary_simplified ${fuzz_target} -- -dict=fuzz/terminals.dict -max_len=256 -only_ascii=1 -runs={{ runs }};
done
# Check minimal dependency versions and MSRV
minimal_versions: install_rust_1_65 install_rust_nightly
cargo +nightly update -Z minimal-versions
cargo +1.65 check \
--workspace --exclude tokio-client --exclude tokio-server \
--all-targets --all-features
cargo +1.65 test \
--workspace --exclude tokio-client --exclude tokio-server --exclude imap-codec-fuzz --exclude imap-types-fuzz \
--all-targets --all-features
cargo update
###############
### INSTALL ###
###############
# Install required tooling (ahead of time)
install: install_rust_1_65 \
install_rust_nightly \
install_rust_nightly_fmt \
install_rust_llvm_tools_preview \
install_cargo_clippy \
install_cargo_deny \
install_cargo_fuzz \
install_cargo_grcov \
install_cargo_hack \
install_cargo_semver_checks
[private]
install_rust_1_65:
rustup toolchain install 1.65 --profile minimal
[private]
install_rust_nightly:
rustup toolchain install nightly --profile minimal
[private]
install_rust_nightly_fmt:
rustup component add --toolchain nightly rustfmt
[private]
install_rust_llvm_tools_preview:
rustup component add llvm-tools-preview
[private]
install_cargo_clippy:
rustup component add clippy
[private]
install_cargo_deny:
cargo install --locked cargo-deny
[private]
install_cargo_fuzz: install_rust_nightly
cargo install cargo-fuzz
[private]
install_cargo_grcov:
cargo install grcov
[private]
install_cargo_hack:
cargo install --locked cargo-hack
[private]
install_cargo_semver_checks:
cargo install --locked cargo-semver-checks