Skip to content

Commit d9b6814

Browse files
committed
space management and use codecov
1 parent 4baa925 commit d9b6814

File tree

3 files changed

+44
-23
lines changed

3 files changed

+44
-23
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ jobs:
126126
# Could you use this to fake the coverage report for your PR? Sure.
127127
# Will anyone be impressed by your amazing coverage? No
128128
# Maybe if codecov wasn't broken we wouldn't need to do this...
129-
./ci/ci-fuzz.sh
130129
bash <(curl -s https://codecov.io/bash) -f target/codecov.json -t "f421b687-4dc2-4387-ac3d-dc3b2528af57"
130+
- name: Run fuzz coverage generation
131+
run: |
132+
./ci/ci-fuzz.sh
131133
132134
benchmark:
133135
runs-on: ubuntu-latest

ci/ci-fuzz.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@
22
set -eox pipefail
33

44
echo -e "\n\nGenerating fuzz coverage report"
5-
# In CI, store coverage in a specific directory for artifact collection
6-
COVERAGE_DIR="coverage-report"
5+
# In CI, store coverage in target directory for consistency with other artifacts
6+
COVERAGE_DIR="target/coverage-report"
77
echo "Installing cargo-llvm-cov..."
88
# Install cargo-llvm-cov if not already installed
99
cargo install cargo-llvm-cov --locked
10+
11+
echo "Cleaning up to save disk space..."
12+
rm -rf target/*
13+
echo "Disk cleanup completed"
14+
15+
1016
echo "Running fuzz coverage generation..."
1117
./contrib/generate_fuzz_coverage.sh --output-dir "$COVERAGE_DIR"
1218
echo "Coverage generation completed. Checking results..."
13-
if [ -f "fuzz/$COVERAGE_DIR/html/index.html" ]; then
14-
echo "✓ Coverage report successfully generated at fuzz/$COVERAGE_DIR/html/index.html"
15-
ls -la "fuzz/$COVERAGE_DIR/html/"
16-
else
17-
echo "✗ Coverage report not found at expected location"
19+
20+
# Upload fuzz coverage to codecov if the file exists (CI only)
21+
if [ -f "target/fuzz-codecov.json" ]; then
22+
echo "Uploading fuzz coverage to codecov..."
23+
bash <(curl -s https://codecov.io/bash) -f "target/fuzz-codecov.json" -F fuzz -t "f421b687-4dc2-4387-ac3d-dc3b2528af57"
1824
fi

contrib/generate_fuzz_coverage.sh

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,37 @@ fi
5252
mkdir -p "$OUTPUT_DIR"
5353

5454
export RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz"
55-
# ignore anything in fuzz directory since we don't want coverage of targets
56-
cargo llvm-cov --html --ignore-filename-regex "fuzz/" --output-dir "$OUTPUT_DIR"
5755

58-
# Check if coverage report was generated successfully
59-
# The report is generated in $OUTPUT_DIR/html/index.html when using --html --output-dir
60-
if [ ! -f "$OUTPUT_DIR/html/index.html" ]; then
61-
echo "Error: Failed to generate coverage report at $OUTPUT_DIR/html/index.html"
62-
# Debug: list what was actually created
63-
echo "Contents of $OUTPUT_DIR:"
64-
ls -la "$OUTPUT_DIR" || echo "Directory $OUTPUT_DIR does not exist"
65-
if [ -d "$OUTPUT_DIR/html" ]; then
66-
echo "Contents of $OUTPUT_DIR/html:"
67-
ls -la "$OUTPUT_DIR/html"
56+
# dont run this command when running in CI
57+
if [ "$CI" != "true" ] && [ "$GITHUB_ACTIONS" != "true" ]; then
58+
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
72+
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..."
78+
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"
6884
fi
69-
exit 1
7085
fi
7186

72-
echo ""
73-
echo "Coverage report generated in $OUTPUT_DIR/html/index.html"
7487

7588

0 commit comments

Comments
 (0)