|
52 | 52 | mkdir -p "$OUTPUT_DIR"
|
53 | 53 |
|
54 | 54 | 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" |
57 | 55 |
|
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" |
68 | 84 | fi
|
69 |
| - exit 1 |
70 | 85 | fi
|
71 | 86 |
|
72 |
| -echo "" |
73 |
| -echo "Coverage report generated in $OUTPUT_DIR/html/index.html" |
74 | 87 |
|
75 | 88 |
|
0 commit comments