ci: nightly cargo-fuzz job for fuzz/ (PR #103 harness)
Add a job to .forgejo/workflows/ci.yml that builds the four libFuzzer targets on nightly (ratchet_frame, qr_decode, dispatch_classify, file_decode) and runs each for 15s. Own registry and target volumes (onionwire-cargo-registry-fuzz / onionwire-target-ci-fuzz), TMPDIR=/target/tmp, own concurrency group (onionwire-ci-pi-fuzz) so the ~12min cold build does not serialize the test/sdk jobs. Path allowlist extended with fuzz/** and scripts/run-fuzz.sh so fuzz-only PRs actually trigger it. Job is a no-op until PR #103 lands on main; the fuzz/ crate is a detached workspace that root cargo test/clippy never sees.
This commit is contained in:
parent
4a06d794f1
commit
bfbbdbf14f
1 changed files with 93 additions and 0 deletions
|
|
@ -17,6 +17,8 @@ on:
|
|||
- "Cargo.toml"
|
||||
- "Cargo.lock"
|
||||
- ".forgejo/workflows/ci.yml"
|
||||
- "fuzz/**"
|
||||
- "scripts/run-fuzz.sh"
|
||||
pull_request:
|
||||
paths:
|
||||
- "src/**"
|
||||
|
|
@ -25,6 +27,8 @@ on:
|
|||
- "Cargo.toml"
|
||||
- "Cargo.lock"
|
||||
- ".forgejo/workflows/ci.yml"
|
||||
- "fuzz/**"
|
||||
- "scripts/run-fuzz.sh"
|
||||
workflow_dispatch:
|
||||
|
||||
# One cargo job on the Pi at a time. Overlapping PR+main runs shared the
|
||||
|
|
@ -44,6 +48,14 @@ env:
|
|||
# jobs' feature-unified artifacts.
|
||||
SDK_CARGO_TARGET_VOLUME: onionwire-target-ci-sdk
|
||||
SDK_BUILD_CONTAINER: onionwire-ci-sdk-${{ github.run_id }}
|
||||
# The fuzz job builds on nightly with a release profile + debug=line-tables-only;
|
||||
# it must not thrash the test/sdk target volumes and needs its own registry cache.
|
||||
FUZZ_REGISTRY_VOLUME: onionwire-cargo-registry-fuzz
|
||||
FUZZ_TARGET_VOLUME: onionwire-target-ci-fuzz
|
||||
FUZZ_BUILD_CONTAINER: onionwire-ci-fuzz-${{ github.run_id }}
|
||||
# libFuzzer writes its -fork dir into TMPDIR; point it at the target volume so
|
||||
# a host tmpfs quota can't OOM-kill the builder.
|
||||
FUZZ_TMP_DIR: /target/tmp
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
|
@ -65,6 +77,7 @@ jobs:
|
|||
-e CARGO_TARGET_DIR=/target \
|
||||
-e CARGO_BUILD_JOBS=2 \
|
||||
-e CARGO_TERM_COLOR=never \
|
||||
-e TMPDIR=/target/tmp \
|
||||
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
||||
-v "$CARGO_TARGET_VOLUME":/target \
|
||||
-w /src \
|
||||
|
|
@ -105,6 +118,7 @@ jobs:
|
|||
-e CARGO_TARGET_DIR=/target \
|
||||
-e CARGO_BUILD_JOBS=2 \
|
||||
-e CARGO_TERM_COLOR=never \
|
||||
-e TMPDIR=/target/tmp \
|
||||
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
||||
-v "$SDK_CARGO_TARGET_VOLUME":/target \
|
||||
-w /src \
|
||||
|
|
@ -119,3 +133,82 @@ jobs:
|
|||
--exclude=./crates/onionwire-sdk/target . \
|
||||
| docker start -a -i "$SDK_BUILD_CONTAINER"
|
||||
docker rm -f "$SDK_BUILD_CONTAINER" > /dev/null
|
||||
|
||||
# Nightly cargo-fuzz harness. The `fuzz/` crate (PR #103) is a detached
|
||||
# workspace with four libFuzzer targets over the untrusted-input parsers —
|
||||
# RatchetState::from_bytes/decrypt, qr::decode, dispatch::classify, file::decode.
|
||||
# Nothing in CI ever compiles this crate, so the targets bit-rot silently: this
|
||||
# job catches it. It only does something useful after PR #103 merges to main.
|
||||
fuzz:
|
||||
runs-on: docker
|
||||
timeout-minutes: 120
|
||||
# The cold fuzz build (~12 min locally for the full Arti + SQLCipher +
|
||||
# vendored-OpenSSL graph) can SERIALIZE other PRs with the same concurrency
|
||||
# group. Give it its own group so a long fuzz build does not block the test/sdk
|
||||
# jobs and the PRs that trigger them.
|
||||
concurrency:
|
||||
group: onionwire-ci-pi-fuzz
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
|
||||
- name: nightly toolchain + cargo-fuzz
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE}"
|
||||
echo "workspace: $GITHUB_WORKSPACE"
|
||||
docker volume create "$FUZZ_REGISTRY_VOLUME" > /dev/null
|
||||
docker volume create "$FUZZ_TARGET_VOLUME" > /dev/null
|
||||
docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null 2>&1 || true
|
||||
docker create --name "$FUZZ_BUILD_CONTAINER" -i \
|
||||
-e CARGO_TARGET_DIR=/target \
|
||||
-e CARGO_BUILD_JOBS=2 \
|
||||
-e CARGO_TERM_COLOR=never \
|
||||
-e TMPDIR=/target/tmp \
|
||||
-e RUSTUP_HOME=/usr/local/rustup \
|
||||
-e CARGO_HOME=/usr/local/cargo \
|
||||
-v "$FUZZ_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
||||
-v "$FUZZ_TARGET_VOLUME":/target \
|
||||
-w /src \
|
||||
"$RUST_IMAGE" \
|
||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
||||
&& rustup toolchain install nightly --profile minimal \
|
||||
&& rustup default nightly \
|
||||
&& cargo install cargo-fuzz --locked \
|
||||
&& export PATH="/usr/local/cargo/bin:$PATH" \
|
||||
&& cd /src/fuzz \
|
||||
&& cargo +nightly fuzz build \
|
||||
&& cargo +nightly fuzz list'
|
||||
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees . \
|
||||
| docker start -a -i "$FUZZ_BUILD_CONTAINER"
|
||||
|
||||
- name: run each fuzz target for 15s
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE}"
|
||||
docker volume create "$FUZZ_REGISTRY_VOLUME" > /dev/null
|
||||
docker volume create "$FUZZ_TARGET_VOLUME" > /dev/null
|
||||
docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null 2>&1 || true
|
||||
docker create --name "$FUZZ_BUILD_CONTAINER" -i \
|
||||
-e CARGO_TARGET_DIR=/target \
|
||||
-e CARGO_BUILD_JOBS=2 \
|
||||
-e CARGO_TERM_COLOR=never \
|
||||
-e TMPDIR=/target/tmp \
|
||||
-e RUSTUP_HOME=/usr/local/rustup \
|
||||
-e CARGO_HOME=/usr/local/cargo \
|
||||
-e FUZZ_SECS=15 \
|
||||
-e FUZZ_JOBS=2 \
|
||||
-v "$FUZZ_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
||||
-v "$FUZZ_TARGET_VOLUME":/target \
|
||||
-w /src \
|
||||
"$RUST_IMAGE" \
|
||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
||||
&& export PATH="/usr/local/cargo/bin:$PATH" \
|
||||
&& cd /src/fuzz \
|
||||
&& bash /src/scripts/run-fuzz.sh'
|
||||
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees . \
|
||||
| docker start -a -i "$FUZZ_BUILD_CONTAINER"
|
||||
docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null
|
||||
|
|
|
|||
Loading…
Reference in a new issue