Skip to content

Commit

Permalink
WIP: cov: ensure we use host llvm version and clear coverage data
Browse files Browse the repository at this point in the history
  • Loading branch information
ahayzen-kdab committed Jan 27, 2025
1 parent e49a9bb commit 619cc9d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/github-cxx-qt-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ jobs:
run: |
rustup default 1.77.2
cargo install grcov
rustup component add llvm-tools rustfmt
rustup component add rustfmt
- run: test -d /usr/lib/llvm-18/bin/
- run: rm -f coverage/*.profraw
- name: build
env:
RUSTFLAGS: -Cinstrument-coverage
Expand All @@ -87,7 +89,7 @@ jobs:
LLVM_PROFILE_FILE: coverage/coverage_data-%p-%m.profraw
run: cargo test --lib --package cxx-qt-gen
- name: generate-report
run: grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/lcov.info --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP
run: grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing --llvm --llvm-path /usr/lib/llvm-18/bin/ -o ./target/debug/lcov.info --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP
- name: upload-report
uses: codecov/codecov-action@v5
with:
Expand Down
19 changes: 15 additions & 4 deletions scripts/grcov_cxx_qt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,30 @@
#
# SPDX-License-Identifier: MIT OR Apache-2.0

# Assumes you have grcov and llvm-tools
# Assumes you have grcov and llvm in a system path
# Install:
# cargo install grcov
# rustup component add llvm-tools

set -ex

# Ensure we are in the right directory
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
cd "$SCRIPTPATH/../"

# Ensure coverage folder is cleared
rm -f "$SCRIPTPATH"/coverage/*.profraw

# Check that the llvm path exists
#
# We can use rustup component add llvm-tools but this can be out of sync
if [ ! -d /usr/lib/llvm-18/bin/ ]; then
echo "LLVM path not found"
fi

export RUSTFLAGS="-Cinstrument-coverage"
export LLVM_PROFILE_FILE="$SCRIPTPATH/coverage/coverage_data-%p-%m.profraw"
cargo build --package cxx-qt-gen
cargo test --package cxx-qt-gen
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/ --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP
echo "Coverage html report generated in $(realpath "$SCRIPTPATH"/../target/debug/html)"
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --llvm --llvm-path=/usr/lib/llvm-18/bin/ -o ./target/debug/ --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP
echo "Coverage html report generated in $(realpath "$SCRIPTPATH"/../target/debug/html)"

0 comments on commit 619cc9d

Please sign in to comment.