-
Notifications
You must be signed in to change notification settings - Fork 2
442 lines (427 loc) · 13.9 KB
/
cicd.yml
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
name: Build and Check
on:
push:
branches: ["main", "cicd", "release", "develop", "develop-gamma"]
pull_request:
branches: ["main"]
schedule:
- cron: "00 01 * * *"
workflow_dispatch:
inputs:
resetBenchmarks:
description: "Reset the benchmark data"
required: true
type: boolean
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: "1"
BENCHMARK_REGRESSION_PERCENT_FAIL: 10
FEATURES: standard,custom,time,chrono,serde,base
jobs:
deny:
name: Check dependencies/ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
rust-version: "1.66.0"
minimal_versions:
needs: [deny]
name: Build and check with minimal versions
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- "1.66.0" # MSRV
- stable
- nightly
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.toolchain }}
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-minimal-versions
# This'll run without checking dev-dependencies
- name: Build with minimal versions
run: cargo minimal-versions check --workspace --ignore-private --all-features --lib --bins
format:
name: Check format with nightly rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --check
base:
needs: [format]
name: Build, check and test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
toolchain:
- "1.66.0" # MSRV
- stable
- nightly
include:
- components: clippy
toolchain: stable
- features: standard,custom,time,chrono,serde,base,with-iai,with-flamegraph
- features: standard,custom,time,chrono,serde,base
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: ${{ matrix.components }}
- name: Prepare
if: matrix.toolchain != 'stable'
run: |
rustup toolchain install stable --no-self-update --component clippy
- uses: Swatinem/rust-cache@v2
with:
key: "${{ matrix.os }}_${{ matrix.toolchain }}"
- name: Info if unix
if: ${{ matrix.os != 'windows-latest' }}
run: |
set -x
uname -a
pwd
rustup --version
rustup show
rustup component list --installed
- name: Info if windows
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: |
set -x
rustup show
rustup component list --installed
- name: Update locked dependencies
if: matrix.toolchain == 'stable' || matrix.toolchain == 'nightly'
run: |
cargo update
- name: Build
run: cargo build --features ${{ matrix.features }}
- name: Lint
run: cargo +stable clippy --features ${{ matrix.features }} --all-targets -- -D warnings
- name: Test
run: cargo test --features ${{ matrix.features }}
cross:
needs: [format]
name: Cross build and test
strategy:
fail-fast: false
matrix:
target:
##### big endian targets #####
- s390x-unknown-linux-gnu
# - sparc64-unknown-linux-gnu
# - powerpc-unknown-linux-gnu
- mips-unknown-linux-gnu
##### little endian targets #####
- i686-unknown-linux-gnu
- i586-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- arm-unknown-linux-gnueabihf
# - riscv64gc-unknown-linux-gnu
# dependency errors: quick-xml
# - wasm32-unknown-emscripten
# dependency errors: criterion
# - x86_64-linux-android
- x86_64-unknown-linux-musl
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.66.0"
- uses: Swatinem/rust-cache@v2
with:
key: "${{ matrix.target }}"
- uses: taiki-e/install-action@cross
- name: Configure cross
run: |
cat <<EOF | tee Cross.toml
[build.env]
passthrough = ["CI", "RUST_BACKTRACE", "CARGO_TERM_COLOR", "CARGO_REGISTRIES_CRATES_IO_PROTOCOL", "CARGO_INCREMENTAL"]
EOF
- name: Info
run: |
set -x
pwd
rustup --version
rustup show
rustup component list --installed
cargo --list
cross --version
- name: Build
run: cross build --features ${{ env.FEATURES }} --target ${{ matrix.target }}
- name: Test
run: cross test --features ${{ env.FEATURES }} --target ${{ matrix.target }}
docs:
needs: [base, cross]
name: Docs/ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run doc tests
run: cargo test --all-features --doc -- --show-output
- name: Check Documentation
run: cargo doc --all-features --no-deps --document-private-items
coverage:
needs: [base, cross]
name: Coverage/ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
- name: Install llvm
run: sudo apt-get -y update && sudo apt-get -y install llvm
- uses: taiki-e/install-action@grcov
- name: Info
run: |
set -x
uname -a
printenv | grep -i -e cargo -e rust -e llvm
cargo -V
rustup -V
rustup show
rustup component list --installed
- name: Create coverage profile
run: |
cat <<EOF | tee ~/.cargo/config
[profile.coverage]
inherits = "dev"
lto = false
debug = true
opt-level = 0
EOF
- name: Clean
run: cargo clean
- name: Build
run: cargo build --features ${{ env.FEATURES }} --profile coverage
- name: Test
run: cargo test --features ${{ env.FEATURES }} --tests --profile coverage
- name: Generate code coverage
run: |
~/.cargo/bin/grcov . \
--llvm-path /usr/bin \
--binary-path target/coverage \
--ignore-not-existing \
--output-type files \
--excl-start 'cov:\s*excl-start' \
--excl-stop 'cov:\s*excl-stop' \
--excl-line '^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\(|.*cov:\s*excl-line)' \
--ignore '**/examples/*' \
--ignore '/*' \
--ignore '[a-zA-Z]:/*' \
--source-dir . | sort -u
~/.cargo/bin/grcov . \
--branch \
--llvm-path /usr/bin \
--binary-path target/coverage \
--ignore-not-existing \
--output-type lcov \
--source-dir . \
--excl-start 'cov:\s*excl-start' \
--excl-stop 'cov:\s*excl-stop' \
--excl-line '^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\(|.*cov:\s*excl-line)' \
--ignore '**/examples/*' \
--ignore '/*' \
--ignore '[a-zA-Z]:/*' \
--output-path lcov.info && test -e lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
files: lcov.info
fail_ci_if_error: false
env:
RUSTFLAGS: "-C instrument-coverage"
LLVM_PROFILE_FILE: "fundu_coverage-%p-%m.profraw"
RUST_BACKTRACE: "0"
fuzzing:
needs: [base, cross]
name: Fuzzy testing/ubuntu-latest
strategy:
fail-fast: false
matrix:
test:
- package: fundu
fuzz_target: f64_like_input
- package: fundu
fuzz_target: parse_single
- package: fundu-gnu
fuzz_target: parsing
runs-on: ubuntu-latest
defaults:
run:
working-directory: "${{ matrix.test.package }}/fuzz"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: llvm-tools
- name: Prepare
run: cargo install cargo-fuzz rustfilt
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.test.fuzz_target }}
workspaces: |
${{ matrix.test.package }}/fuzz -> target
cache-on-failure: true
- name: Run fuzzing for 5 minutes
run: |
dict="dicts/${{ matrix.test.fuzz_target }}.dict"
if test -e "$dict"; then
cargo fuzz run --all-features ${{ matrix.test.fuzz_target }} -- \
-max_total_time=300 \
-print_final_stats=1 \
-print_corpus_stats=1 \
-verbosity=2 \
-dict="$dict"
else
cargo fuzz run --all-features ${{ matrix.test.fuzz_target }} -- \
-max_total_time=300 \
-print_final_stats=1 \
-print_corpus_stats=1 \
-verbosity=2
fi
- name: Create coverage.profdata
run: cargo fuzz coverage ${{ matrix.test.fuzz_target }}
- name: Create lcov coverage report
run: |
llvm_cov_bin=$(realpath -e $(rustc --print target-libdir)/../bin/llvm-cov)
$llvm_cov_bin export \
target/x86_64-unknown-linux-gnu/coverage/x86_64-unknown-linux-gnu/release/${{ matrix.test.fuzz_target }} \
--instr-profile=coverage/${{ matrix.test.fuzz_target }}/coverage.profdata \
--format=lcov \
--ignore-filename-regex='/rustc/.*|\.cargo/registry/.*|fuzz/fuzz_targets/.*' \
-Xdemangler='rustfilt' > lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
files: lcov.info
name: ${{ matrix.test.package }}-${{ matrix.test.fuzz_target }}
override_branch: fuzzy-testing
fail_ci_if_error: false
env:
RUSTFLAGS: "-C instrument-coverage"
LLVM_PROFILE_FILE: "fundu_fuzzy_coverage-%p-%m.profraw"
benchmarks:
needs: [base, cross]
name: Benchmarks/ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.66.0"
- uses: taiki-e/install-action@cargo-binstall
- name: Install iai-callgrind-runner
run: |
version=$(cargo metadata --format-version=1 |\
jq '.packages[] | select(.name == "iai-callgrind").version' |\
tr -d '"'
)
cargo binstall --no-confirm iai-callgrind-runner@$version
- uses: Swatinem/rust-cache@v2
- name: Prepare
run: |
sudo apt-get -y update && sudo apt-get -y install valgrind
- name: Download reference benchmarks
if: ${{ !inputs.resetBenchmarks }}
uses: dawidd6/action-download-artifact@v6
with:
workflow_conclusion: success
name: iai-callgrind-benchmarks
check_artifacts: true
if_no_artifact_found: warn
- name: Run iai-callgrind benchmarks
run: |
benches=$(cargo metadata --no-deps --format-version=1 |\
jq '.packages[].targets[] | select(any(.kind[]; . == "bench") and (."required-features" and any(."required-features"[]; . == "with-iai"))) | .name' |\
tr -d '"'
)
args=()
while IFS=$'\n' read -r bench; do args+=(--bench); args+=("$bench"); done <<<"$benches"
cargo bench --all-features ${args[@]}
- uses: actions/upload-artifact@v4
with:
name: iai-callgrind-benchmarks
path: "target/iai"
miri:
needs: [base, cross]
name: Tests/Miri
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu # 32-bit
- mips64-unknown-linux-gnuabi64 # big-endian
- aarch64-unknown-linux-gnu
- arm-unknown-linux-gnueabihf
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri
# - uses: Swatinem/rust-cache@v2
# with:
# key: ${{ matrix.target }}
# cache-directories: /home/runner/.cache/miri
- uses: taiki-e/install-action@cross
if: matrix.target != 'x86_64-unknown-linux-gnu'
- name: Info
run: |
set -x
pwd
rustup --version
rustup show
rustup component list --installed
cargo --list
- name: Setup cross/miri
run: |
cargo miri setup
case ${{ matrix.target }} in
x86_64-unknown-linux-gnu )
;;
* )
cat <<EOF | tee Cross.toml
[build.env]
passthrough = ["CI", "RUST_BACKTRACE", "CARGO_TERM_COLOR", "CARGO_REGISTRIES_CRATES_IO_PROTOCOL", "CARGO_INCREMENTAL"]
EOF
;;
esac
- name: Test with miri
run: |
case ${{ matrix.target }} in
x86_64-unknown-linux-gnu )
cargo miri test --features ${{ env.FEATURES }}
;;
* )
cross miri test --features ${{ env.FEATURES }} --target ${{ matrix.target }}
;;
esac