Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 45 additions & 32 deletions .github/workflows/fuzzing.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Fuzzing

# spell-checker:ignore fuzzer dtolnay Swatinem
# spell-checker:ignore (people) dtolnay Swatinem taiki-e
# spell-checker:ignore (misc) fuzzer

on:
pull_request:
Expand All @@ -19,16 +20,17 @@ concurrency:
jobs:
uufuzz-examples:
name: Build and test uufuzz examples
env:
CARGO_INCREMENTAL: 0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: "uufuzz-cache-key"
cache-directories: "fuzz/target"
#- uses: Swatinem/rust-cache@v2
#with:
#shared-key: "uufuzz-cache-key"
#cache-directories: "fuzz/target"
- name: Build uufuzz library
run: |
cd fuzz/uufuzz
Expand Down Expand Up @@ -59,15 +61,20 @@ jobs:
with:
persist-credentials: false
- name: Install `cargo-fuzz`
run: |
echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}" # Use -Z
cargo install cargo-fuzz --locked
- uses: Swatinem/rust-cache@v2
uses: taiki-e/install-action@v2
with:
shared-key: "cargo-fuzz-cache-key"
cache-directories: "fuzz/target"
tool: cargo-fuzz
- name: Emulate a nightly toolchain
run: |
echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}"
#- uses: Swatinem/rust-cache@v2
#with:
#shared-key: "cargo-fuzz-cache-key"
#cache-directories: "fuzz/target"
- name: Run `cargo-fuzz build`
run: cargo fuzz build
# Force the correct target
# https://github.com/rust-fuzz/cargo-fuzz/issues/398
run: cargo fuzz build --target $(rustc --print host-tuple)

fuzz-run:
needs: fuzz-build
Expand All @@ -76,6 +83,7 @@ jobs:
timeout-minutes: 5
env:
RUN_FOR: 60
CARGO_INCREMENTAL: 0
strategy:
matrix:
test-target:
Expand Down Expand Up @@ -104,27 +112,32 @@ jobs:
with:
persist-credentials: false
- name: Install `cargo-fuzz`
run: |
echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}" # Use nightly
cargo install cargo-fuzz --locked
- uses: Swatinem/rust-cache@v2
uses: taiki-e/install-action@v2
with:
shared-key: "cargo-fuzz-cache-key"
cache-directories: "fuzz/target"
- name: Restore Cached Corpus
uses: actions/cache/restore@v5
with:
key: corpus-cache-${{ matrix.test-target.name }}
path: |
fuzz/corpus/${{ matrix.test-target.name }}
tool: cargo-fuzz
- name: Emulate a nightly toolchain
run: |
echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}"
#- uses: Swatinem/rust-cache@v2
#with:
#shared-key: "cargo-fuzz-cache-key"
#cache-directories: "fuzz/target"
#- name: Restore Cached Corpus
#uses: actions/cache/restore@v5
#with:
#key: corpus-cache-${{ matrix.test-target.name }}
#path: |
#fuzz/corpus/${{ matrix.test-target.name }}
- name: Run ${{ matrix.test-target.name }} for XX seconds
id: run_fuzzer
shell: bash
continue-on-error: ${{ !matrix.test-target.should_pass }}
run: |
mkdir -p fuzz/stats
STATS_FILE="fuzz/stats/${{ matrix.test-target.name }}.txt"
cargo fuzz run ${{ matrix.test-target.name }} -- -max_total_time=${{ env.RUN_FOR }} -timeout=${{ env.RUN_FOR }} -detect_leaks=0 -print_final_stats=1 2>&1 | tee "$STATS_FILE"
# Force the correct target
# https://github.com/rust-fuzz/cargo-fuzz/issues/398
cargo fuzz run --target $(rustc --print host-tuple) ${{ matrix.test-target.name }} -- -max_total_time=${{ env.RUN_FOR }} -timeout=${{ env.RUN_FOR }} -detect_leaks=0 -print_final_stats=1 2>&1 | tee "$STATS_FILE"

# Extract key stats from the output
if grep -q "stat::number_of_executed_units" "$STATS_FILE"; then
Expand Down Expand Up @@ -193,12 +206,12 @@ jobs:
fi

echo "" >> $GITHUB_STEP_SUMMARY
- name: Save Corpus Cache
uses: actions/cache/save@v5
with:
key: corpus-cache-${{ matrix.test-target.name }}
path: |
fuzz/corpus/${{ matrix.test-target.name }}
#- name: Save Corpus Cache
#uses: actions/cache/save@v5
#with:
#key: corpus-cache-${{ matrix.test-target.name }}
#path: |
#fuzz/corpus/${{ matrix.test-target.name }}
- name: Upload Stats
uses: actions/upload-artifact@v6
with:
Expand Down
Loading