mirror of
https://github.com/ankitects/anki.git
synced 2026-07-22 03:17:05 -04:00
## Linked issue (required) Refs #5134 ## Summary / motivation (required) When running ci, instead of manually compiling cargo-llvm-cov and cargo-nextest when not cached, this pr pulls them in as prebuilt binaries instead ## Steps to reproduce (required, use N/A if not applicable) N/A ## How to test (required) CI should pass, and running `./check` and `just test --coverage` should work locally too ### 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. ### Details Continuing from https://github.com/ankitects/anki/issues/5134#issuecomment-4936603431, we can avoid installing the crates globally when run locally, but in ci it doesn't really matter so we can use install-action as per normal. W.r.t nextest's features, all `default-no-update` does is remove its ability to self-update. Since we're puling in prebuilt binaries during ci there's no difference I've left out n2 for now, as without a release workflow on its repo or on anki's fork, we'd still have to compile it ourselves (caching it can be unsafe, but it sort of is already cached by setup-rust-toolchain?) ## Scope - [x] This PR is focused on one change (no unrelated edits).
27 lines
687 B
Bash
Executable File
27 lines
687 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
html="$1"
|
|
|
|
outdir="out/coverage/rust"
|
|
LLVMCOVPATH="out/bin"
|
|
|
|
mkdir -p $outdir $LLVMCOVPATH
|
|
|
|
if [[ "${CI:-}" == "true" ]]; then
|
|
# prebuilt binary shouldve been installed
|
|
cargo_cmd="cargo"
|
|
else
|
|
cargo_cmd="$LLVMCOVPATH/cargo-llvm-cov"
|
|
test -x "$cargo_cmd" || cargo install cargo-llvm-cov --version 0.8.4 --locked --root out
|
|
fi
|
|
|
|
ANKI_TEST_MODE=1 "$cargo_cmd" llvm-cov --workspace --locked --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 --html --output-dir $outdir
|
|
echo "Rust coverage report: $outdir/html/index.html"
|
|
fi
|