Skip to content

Commit 3453a5e

Browse files
committed
add coverage report generation in CI
adds the coverage report generation in CI . Also make the coverage script more CI friendly.
1 parent 10679bb commit 3453a5e

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

ci/ci-tests.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,15 @@ RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
137137
RUSTFLAGS="--cfg=async_payments" cargo test --verbose --color always -p lightning
138138
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
139139
RUSTFLAGS="--cfg=lsps1_service" cargo test --verbose --color always -p lightning-liquidity
140+
141+
# Generate fuzz coverage report
142+
echo -e "\n\nGenerating fuzz coverage report"
143+
if [ -n "$CI" ]; then
144+
# In CI, store coverage in a specific directory for artifact collection
145+
COVERAGE_DIR="coverage-report"
146+
mkdir -p "$COVERAGE_DIR"
147+
./contrib/generate_fuzz_coverage.sh --output-dir "$COVERAGE_DIR"
148+
else
149+
# Local development
150+
./contrib/generate_fuzz_coverage.sh
151+
fi

contrib/generate_fuzz_coverage.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
set -e
33
set -x
44

5+
# Parse command line arguments
6+
OUTPUT_DIR="target/llvm-cov/html"
7+
while [[ $# -gt 0 ]]; do
8+
case $1 in
9+
--output-dir)
10+
OUTPUT_DIR="$2"
11+
shift 2
12+
;;
13+
*)
14+
echo "Unknown option: $1"
15+
echo "Usage: $0 [--output-dir OUTPUT_DIRECTORY]"
16+
exit 1
17+
;;
18+
esac
19+
done
20+
521
# Check if we're in the root directory, if so change to fuzz
622
if [ -d "fuzz" ]; then
723
cd fuzz
@@ -32,11 +48,20 @@ if [ "$show_corpus_message" = true ]; then
3248
echo ""
3349
fi
3450

51+
# Create output directory if it doesn't exist
52+
mkdir -p "$OUTPUT_DIR"
53+
3554
export RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz"
3655
# ignore anything in fuzz directory since we don't want coverage of targets
37-
cargo llvm-cov --html --ignore-filename-regex "fuzz/"
56+
cargo llvm-cov --html --ignore-filename-regex "fuzz/" --output-dir "$OUTPUT_DIR"
57+
58+
# Check if coverage report was generated successfully
59+
if [ ! -f "$OUTPUT_DIR/index.html" ]; then
60+
echo "Error: Failed to generate coverage report"
61+
exit 1
62+
fi
3863

3964
echo ""
40-
echo "Coverage report generated in target/llvm-cov/html/index.html"
65+
echo "Coverage report generated in $OUTPUT_DIR/index.html"
4166

4267

0 commit comments

Comments
 (0)