name: Fuzzing
on:
pull_request: {}
push:
branches: [main]
workflow_dispatch: {}
jobs:
fuzz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-fuzz
run: cargo install cargo-fuzz
- name: Restore fuzz corpus and dictionary
uses: actions/cache/restore@v4
with:
path: |
fuzz/corpus
fuzz/dictionary.txt
key: fuzz-corpus
- name: Run fuzzing (short)
run: |
DICT_ARG=""
if [ -f fuzz/dictionary.txt ]; then
echo "Using existing dictionary"
DICT_ARG="-dict=fuzz/dictionary.txt"
fi
cargo +nightly fuzz run generate_word -- -max_total_time=30 $DICT_ARG 2>&1 | tee fuzz_output.txt
- name: Extract recommended dictionary
if: always()
run: |
sed -n '/^###### Recommended dictionary/,/^###### End of recommended dictionary/p' fuzz_output.txt | grep -E '^"' > fuzz/dictionary_new.txt || true
if [ -s fuzz/dictionary_new.txt ]; then
mv fuzz/dictionary_new.txt fuzz/dictionary.txt
fi
echo "Dictionary contents:"
cat fuzz/dictionary.txt 2>/dev/null || echo "(empty)"
- name: Delete old cache
if: always() && github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh cache delete fuzz-corpus || true
- name: Save fuzz corpus and dictionary
uses: actions/cache/save@v4
if: always() && github.ref == 'refs/heads/main'
with:
path: |
fuzz/corpus
fuzz/dictionary.txt
key: fuzz-corpus