Files
qdrant/tools/coverage.sh
Kumar Shivendu 5e7d644c4c Setup code coverage reports (#5751)
* Setup code coverage for Rust tests

* Add API key env var for codecov

* Save code coverage report for upload

* Trigger CI

* Try without explicit build step

* Run coverage job on self hosted runner

* Fix mistake because of which is was running fewer tests

* Run coverage on ubuntu latest

* Trigger CI

* fix name

* run coverage on all os

* Adjust after rebase to dev

* Avoid running coverage in other jobs

* fix test job

* reset test workflow

* Trigger CI

* run coverage after tests

* Add script to monitor resources

* fix indentation

* remove coverage dependency on test job

* fix needs field

* add monitoring script

* Run tail -f to monitor resources concurrently with tests

* Split commands

* Use --jobs=1 to possibly minimize RAM

* Try generating coverage one by one

* Dont clean coverage artifacts

* Merge .lcov files with lcov command

* Upload merged lcov.info file

* Run coverage for fewer packages

* Improve coverage script

* Move coverage.sh to tools dir

* Prepare for review

* Improve CI output and failure handling

* Generate HTML report if running locally

* Cleanup

* Run coverage on schedule and only for dev branch
2025-02-11 14:36:44 +01:00

38 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Usage: tools/coverage.sh
#
# For running on low RAM machines like Github CI, Use `RUN_PER_PACKAGE=true tools/coverage.sh`
#
# If using locally, occasionally run `cargo llvm-cov clean` to avoid bloating `target/llvm-cov-target` dir with .profraw files
RUN_PER_PACKAGE=${RUN_PER_PACKAGE:-"false"}
if [ "$RUN_PER_PACKAGE" == "false" ]; then
# Run for the entire workspace in one shot. This assumes that the machine has enough memory
cargo llvm-cov --no-clean nextest --profile ci --workspace --lcov --output-path "lcov.info"
cargo llvm-cov report --html
exit 0
fi
PACKAGES=($(cargo metadata --format-version 1 | jq -r '.workspace_members[] | split("/") | .[-1] | split("#")[0]' | sort))
REPORT_DIR="target/llvm-cov/package-reports"
echo "Workspace packages: ${PACKAGES[*]}"
mkdir -p "$REPORT_DIR"
LCOV_COMMAND_ARGS=""
for PACKAGE in "${PACKAGES[@]}"; do
echo "Testing PACKAGE with coverage: $PACKAGE"
# Profile "ci" is configured in .config/nextest.toml
cargo llvm-cov --no-clean nextest --profile ci -p "$PACKAGE" --lcov --output-path "$REPORT_DIR/$PACKAGE.info"
LCOV_COMMAND_ARGS="${LCOV_COMMAND_ARGS} -a $REPORT_DIR/$PACKAGE.info"
done
if [ -n "$LCOV_COMMAND_ARGS" ]; then
lcov $LCOV_COMMAND_ARGS --output-file lcov.info
fi