File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed
Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -71,11 +71,22 @@ jobs:
7171 steps :
7272 - name : Checkout repository
7373 uses : actions/checkout@v4
74+ # Note we need to match the LLVM and Rust versions
75+ #
76+ # See versions from the table in this link
77+ # https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#get-coverage-of-cc-code-linked-to-rust-librarybinary
78+ - name : Install llvm 17
79+ run : |
80+ sudo apt-get update && sudo apt-get install -y llvm-17
81+ test -d /usr/lib/llvm-17/bin/
7482 - name : Setup toolchain
7583 run : |
84+ # Note that the llvm version needs to match, see the link above
7685 rustup default 1.77.2
7786 cargo install grcov
78- rustup component add llvm-tools rustfmt
87+ rustup component add rustfmt
88+ # Ensure we do not have any existing coverage files
89+ - run : rm -f coverage/*.profraw
7990 - name : build
8091 env :
8192 RUSTFLAGS : -Cinstrument-coverage
8798 LLVM_PROFILE_FILE : coverage/coverage_data-%p-%m.profraw
8899 run : cargo test --lib --package cxx-qt-gen
89100 - name : generate-report
90- 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
101+ run : grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing --llvm --llvm-path /usr/lib/llvm-17/bin/ - o ./target/debug/lcov.info --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP
91102 - name : upload-report
92103 uses : codecov/codecov-action@v5
93104 with :
Original file line number Diff line number Diff line change 55#
66# SPDX-License-Identifier: MIT OR Apache-2.0
77
8- # Assumes you have grcov and llvm-tools
8+ # Assumes you have grcov and llvm in a system path
99# Install:
1010# cargo install grcov
11- # rustup component add llvm-tools
1211set -ex
12+
1313# Ensure we are in the right directory
1414SCRIPT=$( realpath " $0 " )
1515SCRIPTPATH=$( dirname " $SCRIPT " )
1616cd " $SCRIPTPATH /../"
1717
18+ # Ensure coverage folder is cleared
19+ rm -f " $SCRIPTPATH " /coverage/* .profraw
20+
21+ # Check that the llvm path exists
22+ #
23+ # We can use rustup component add llvm-tools but this can be out of sync
24+ # See versions from the table in this link
25+ # https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#get-coverage-of-cc-code-linked-to-rust-librarybinary
26+ if [ ! -d /usr/lib/llvm-17/bin/ ]; then
27+ echo " LLVM 17 not found"
28+ fi
29+
1830export RUSTFLAGS=" -Cinstrument-coverage"
1931export LLVM_PROFILE_FILE=" $SCRIPTPATH /coverage/coverage_data-%p-%m.profraw"
2032cargo build --package cxx-qt-gen
2133cargo test --package cxx-qt-gen
22- 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
23- echo " Coverage html report generated in $( realpath " $SCRIPTPATH " /../target/debug/html) "
34+ grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --llvm --llvm-path=/usr/lib/llvm-17/bin/ - o ./target/debug/ --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP
35+ echo " Coverage html report generated in $( realpath " $SCRIPTPATH " /../target/debug/html) "
You can’t perform that action at this time.
0 commit comments