mirror of
https://github.com/ankitects/anki.git
synced 2026-09-10 08:39:22 -04:00
## Linked issue Related: https://github.com/ankitects/anki/pull/5102#issuecomment-4923922894 ## Summary / motivation This adds a new Cargo profile (`ci`) for use in all Rust build commands on CI. The goal is to reduce unnecessary recompilation of the same crates in dev/release profiles. ## Steps to reproduce (before) View the logs of the last CI run on main and notice that some crates are getting compiled with the `release` profile, e.g. compilation ends with "Finished `release` profile [optimized]". ## How to test (after) View the logs of the last CI run in this PR and confirm all Rust compilation commands end with "Finished `ci` profile [unoptimized]", indicating that only a single profile is being used. ### Checklist (minimum) - [x] I ran `./ninja check` or an equivalent relevant check locally. - [ ] I added or updated tests when the change is non-trivial or behavior changed. ## Scope - [x] This PR is focused on one change (no unrelated edits).
38 lines
1.0 KiB
Bash
Executable File
38 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
html="$1"
|
|
|
|
outdir="out/coverage/rust"
|
|
LLVMCOVPATH="out/bin"
|
|
|
|
mkdir -p $outdir $LLVMCOVPATH
|
|
|
|
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-out/rust}"
|
|
|
|
if [[ "${CI:-}" == "true" ]]; then
|
|
# prebuilt binary shouldve been installed
|
|
cargo_cmd="cargo"
|
|
profile=ci
|
|
else
|
|
cargo_cmd="$LLVMCOVPATH/cargo-llvm-cov"
|
|
test -x "$cargo_cmd" || cargo install cargo-llvm-cov --version 0.8.4 --locked --root out
|
|
test -x "$LLVMCOVPATH/cargo-nextest" || cargo install cargo-nextest \
|
|
--version 0.9.99 --locked --no-default-features --features default-no-update --root out
|
|
profile=dev
|
|
fi
|
|
|
|
export PATH="$LLVMCOVPATH:$PATH"
|
|
|
|
ANKI_TEST_MODE=1 "$cargo_cmd" llvm-cov nextest --workspace --locked \
|
|
--cargo-profile "$profile" \
|
|
--json --summary-only \
|
|
--output-path $outdir/coverage-summary.json --fail-under-lines 64
|
|
|
|
if [ "$html" = "--html" ]; then
|
|
ANKI_TEST_MODE=1 "$cargo_cmd" llvm-cov report --profile "$profile" \
|
|
--html --output-dir $outdir
|
|
echo "Rust coverage report: $outdir/html/index.html"
|
|
fi
|