Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* [Fuzzing on Windows](./cargo-fuzz/windows.md)
* [Setup](./cargo-fuzz/windows/setup.md)
* [Fuzzing DLLs](./cargo-fuzz/windows/dll-fuzzing.md)
* [Fuzzing in CI](./cargo-fuzz/ci.md)
* [Fuzzing with afl.rs](./afl.md)
* [Setup](./afl/setup.md)
* [Tutorial](./afl/tutorial.md)
Expand Down
64 changes: 64 additions & 0 deletions src/cargo-fuzz/ci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Fuzzing in CI

It can be helpful, as a smoke test, to build and run your fuzz targets for a
small amount of time in CI.

If your CI provider of choice is not listed here, feel free to send a PR adding
it.

## GitHub Workflows

```yaml
name: Smoke-Test Fuzz Targets

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
fuzz:
runs-on: ubuntu-latest

env:
# The version of `cargo-fuzz` to install and use.
CARGO_FUZZ_VERSION: 0.12.0

# The number of seconds to run the fuzz target. 300 seconds = 5 minutes.
FUZZ_TIME: 300

strategy:
matrix:
include:
# TODO: List your fuzz targets here.
- fuzz_target: my_first_fuzz_target
- fuzz_target: my_second_fuzz_target
# etc...

steps:
- uses: actions/checkout@v4

# Install the nightly Rust channel.
- run: rustup toolchain install nightly
- run: rustup default nightly

# Install and cache `cargo-fuzz`.
- uses: actions/cache@v4
with:
path: ${{ runner.tool_cache }}/cargo-fuzz
key: cargo-fuzz-bin-${{ env.CARGO_FUZZ_VERSION }}
- run: echo "${{ runner.tool_cache }}/cargo-fuzz/bin" >> $GITHUB_PATH
- run: cargo install --root "${{ runner.tool_cache }}/cargo-fuzz" --version ${{ env.CARGO_FUZZ_VERSION }} cargo-fuzz --locked

# Build and then run the fuzz target.
- run: cargo fuzz build ${{ matrix.fuzz_target }}
- run: cargo fuzz run ${{ matrix.fuzz_target }} -- -max_total_time=${{ env.FUZZ_TIME }}

# Upload fuzzing artifacts on failure for post-mortem debugging.
- uses: actions/upload-artifact@v4
if: failure()
with:
name: fuzzing-artifacts-${{ matrix.fuzz_target }}-${{ github.sha }}
path: fuzz/artifacts
```