Skip to content

Commit eac01d0

Browse files
authored
Merge pull request #3925 from TheBlueMatt/2025-07-3718-followups
Simplify fuzzing coverage (CI) scripts somewhat
2 parents 2f9898c + 37cd32d commit eac01d0

File tree

3 files changed

+18
-53
lines changed

3 files changed

+18
-53
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,20 @@ jobs:
125125
cargo install cargo-llvm-cov
126126
export RUSTFLAGS="-Coverflow-checks=off"
127127
cargo llvm-cov --features rest-client,rpc-client,tokio,serde --codecov --hide-instantiations --output-path=target/codecov.json
128+
curl --verbose -O https://cli.codecov.io/latest/linux/codecov
129+
chmod +x codecov
128130
# Could you use this to fake the coverage report for your PR? Sure.
129131
# Will anyone be impressed by your amazing coverage? No
130132
# Maybe if codecov wasn't broken we wouldn't need to do this...
131-
bash <(curl -s https://codecov.io/bash) -f target/codecov.json -t "f421b687-4dc2-4387-ac3d-dc3b2528af57"
133+
./codecov --verbose upload-process --disable-search --fail-on-error -f target/codecov.json -t "f421b687-4dc2-4387-ac3d-dc3b2528af57" -F 'tests'
134+
cargo clean
132135
- name: Run fuzz coverage generation
133136
run: |
134-
./ci/ci-fuzz.sh
137+
./contrib/generate_fuzz_coverage.sh --output-dir `pwd` --output-codecov-json
138+
# Could you use this to fake the coverage report for your PR? Sure.
139+
# Will anyone be impressed by your amazing coverage? No
140+
# Maybe if codecov wasn't broken we wouldn't need to do this...
141+
./codecov --verbose upload-process --disable-search --fail-on-error -f fuzz-codecov.json -t "f421b687-4dc2-4387-ac3d-dc3b2528af57" -F 'fuzzing'
135142
136143
benchmark:
137144
runs-on: ubuntu-latest

ci/ci-fuzz.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

contrib/generate_fuzz_coverage.sh

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
#!/bin/bash
2-
set -e
3-
set -x
2+
set -ex
43

54
# Parse command line arguments
65
OUTPUT_DIR="coverage-report"
6+
OUTPUT_CODECOV_JSON=0
77
while [[ $# -gt 0 ]]; do
88
case $1 in
99
--output-dir)
1010
OUTPUT_DIR="$2"
1111
shift 2
1212
;;
13+
--output-codecov-json)
14+
OUTPUT_CODECOV_JSON=1
15+
shift 1
16+
;;
1317
*)
1418
echo "Unknown option: $1"
1519
echo "Usage: $0 [--output-dir OUTPUT_DIRECTORY]"
@@ -54,34 +58,12 @@ mkdir -p "$OUTPUT_DIR"
5458
export RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz"
5559

5660
# dont run this command when running in CI
57-
if [ "$CI" != "true" ] && [ "$GITHUB_ACTIONS" != "true" ]; then
61+
if [ "$OUTPUT_CODECOV_JSON" = "0" ]; then
5862
cargo llvm-cov --html --ignore-filename-regex "fuzz/" --output-dir "$OUTPUT_DIR"
59-
60-
# Check if coverage report was generated successfully
61-
# The report is generated in $OUTPUT_DIR/html/index.html when using --html --output-dir
62-
if [ ! -f "$OUTPUT_DIR/html/index.html" ]; then
63-
echo "Error: Failed to generate coverage report at $OUTPUT_DIR/html/index.html"
64-
echo "Contents of $OUTPUT_DIR:"
65-
ls -la "$OUTPUT_DIR" || echo "Directory $OUTPUT_DIR does not exist"
66-
if [ -d "$OUTPUT_DIR/html" ]; then
67-
echo "Contents of $OUTPUT_DIR/html:"
68-
ls -la "$OUTPUT_DIR/html"
69-
fi
70-
exit 1
71-
fi
7263
echo "Coverage report generated in $OUTPUT_DIR/html/index.html"
73-
fi
74-
75-
# Generate codecov JSON format if running in CI environment
76-
if [ "$CI" = "true" ] || [ "$GITHUB_ACTIONS" = "true" ]; then
77-
echo "CI environment detected, generating codecov JSON format..."
64+
else
7865
cargo llvm-cov --codecov --ignore-filename-regex "fuzz/" --output-path "$OUTPUT_DIR/fuzz-codecov.json"
79-
80-
if [ -f "$OUTPUT_DIR/fuzz-codecov.json" ] && [[ "$OUTPUT_DIR" == *"target/"* ]]; then
81-
TARGET_DIR="../target"
82-
cp "$OUTPUT_DIR/fuzz-codecov.json" "$TARGET_DIR/fuzz-codecov.json"
83-
echo "Fuzz codecov report copied to $TARGET_DIR/fuzz-codecov.json"
84-
fi
66+
echo "Fuzz codecov report available at $OUTPUT_DIR/fuzz-codecov.json"
8567
fi
8668

8769

0 commit comments

Comments
 (0)