mirror of
https://github.com/ankitects/anki.git
synced 2026-07-23 09:36:49 -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).
36 lines
1.1 KiB
Batchfile
36 lines
1.1 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
rem cargo-llvm-cov's llvm-profdata uses the host toolchain, which is incompatible
|
|
rem with the profraw files produced when running on Windows ARM64.
|
|
if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
|
|
echo Rust coverage is not supported on Windows ARM64 ^(llvm-profdata format mismatch^).
|
|
echo Run on Linux or let CI enforce coverage.
|
|
exit /b 0
|
|
)
|
|
|
|
set "outdir=out\coverage\rust"
|
|
set "LLVMCOVPATH=out\bin"
|
|
|
|
if not exist %outdir% mkdir %outdir%
|
|
|
|
if "%CI%"=="true" (
|
|
rem prebuilt binary shouldve been installed earlier
|
|
set "CARGO_CMD=cargo"
|
|
) else (
|
|
if not exist %LLVMCOVPATH% mkdir %LLVMCOVPATH%
|
|
if not exist %LLVMCOVPATH%\cargo-llvm-cov.exe (
|
|
cargo install cargo-llvm-cov --version 0.8.4 --locked --root out || exit /b 1
|
|
)
|
|
set "CARGO_CMD=%LLVMCOVPATH%\cargo-llvm-cov.exe"
|
|
)
|
|
|
|
set "ANKI_TEST_MODE=1"
|
|
"%CARGO_CMD%" llvm-cov --workspace --locked --json --summary-only ^
|
|
--output-path %outdir%\coverage-summary.json --fail-under-lines 64 || exit /b 1
|
|
|
|
if "%1"=="--html" (
|
|
"%CARGO_CMD%" llvm-cov report --html --output-dir %outdir% || exit /b 1
|
|
echo Rust coverage report: %outdir%\html\index.html
|
|
)
|