Skip to content

Commit 98ed0ac

Browse files
committed
add llvm-cov installation to amke file
Signed-off-by: Sayan Paul <paul.sayan@gmail.com>
1 parent fe3755e commit 98ed0ac

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,10 @@ jobs:
6767
persist-credentials: false
6868
- name: Fix git trust
6969
run: git config --global --add safe.directory /__w/greenboot-rs/greenboot-rs
70-
- name: Install cargo-llvm-cov
71-
run: cargo install cargo-llvm-cov
7270
- name: Build
73-
run: cargo build
71+
run: make build
7472
- name: Run tests with coverage
75-
run: |
76-
cargo llvm-cov test -- --test-threads=1
77-
cargo llvm-cov report --html --output-dir tests/coverage
73+
run: make test-coverage
7874
- name: Upload coverage report (HTML artifact)
7975
uses: actions/upload-artifact@v4
8076
with:

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ PLATFORMS = $(shell (echo {x86_64,aarch64,powerpc64le,s390x}-unknown-linux-gnu))
1010
LLVM_COV ?= /usr/bin/llvm-cov
1111
LLVM_PROFDATA ?= /usr/bin/llvm-profdata
1212
COVERAGE_OUTPUT_DIR ?= tests/coverage
13-
CARGO_LLVM_COV ?= $(shell command -v cargo-llvm-cov 2>/dev/null)
13+
export PATH := $(HOME)/.cargo/bin:$(PATH)
1414
GREENBOOT_RUST_DEPENDENCIES = rust-anyhow+default-devel \
1515
rust-clap+derive-devel \
1616
rust-clap+default-devel \
@@ -95,10 +95,14 @@ test-coverage:
9595
echo " Install it with: sudo dnf install llvm"; \
9696
exit 1; \
9797
fi
98-
98+
@if ! command -v cargo-llvm-cov >/dev/null 2>&1; then \
99+
echo "cargo-llvm-cov not found, installing..."; \
100+
cargo install cargo-llvm-cov; \
101+
fi
99102
@echo "Running test coverage (results will be in $(COVERAGE_OUTPUT_DIR))..."
100-
sudo LLVM_COV=$(LLVM_COV) LLVM_PROFDATA=$(LLVM_PROFDATA) cargo llvm-cov test -- --test-threads=1
101-
sudo LLVM_COV=$(LLVM_COV) LLVM_PROFDATA=$(LLVM_PROFDATA) cargo llvm-cov report --html --output-dir $(COVERAGE_OUTPUT_DIR)
103+
sudo PATH=$(HOME)/.cargo/bin:$$PATH LLVM_COV=$(LLVM_COV) LLVM_PROFDATA=$(LLVM_PROFDATA) cargo llvm-cov test -- --test-threads=1; \
104+
test_exit=$$?; \
105+
sudo PATH=$(HOME)/.cargo/bin:$$PATH LLVM_COV=$(LLVM_COV) LLVM_PROFDATA=$(LLVM_PROFDATA) cargo llvm-cov report --html --output-dir $(COVERAGE_OUTPUT_DIR)
102106
sudo chmod -R 777 $(COVERAGE_OUTPUT_DIR)
103107
@echo "Coverage report generated at $(COVERAGE_OUTPUT_DIR)/html/index.html"
104108

0 commit comments

Comments
 (0)