Skip to content

Update cargo-fuzz setup; split fuzz_value_sanitize so it runs #6372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
33 changes: 33 additions & 0 deletions .github/workflows/cargo-hack-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Cargo Hack Check

on:
workflow_call:
inputs:
rust-nightly-version:
description: Nightly toolchain to use.
required: false
type: string
default: nightly
Comment on lines +5 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s not entirely clear why this workflow requires this input. Could you elaborate?

We might consider simplifying by hardcoding the version in the fuzz-targets job or by using an environment variable instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, cargo fuzz needs nightly. However we could follow the rule of three and inline it for now directly in the job.


env:
RUST_BACKTRACE: full
Expand Down Expand Up @@ -116,3 +122,30 @@ jobs:

- name: Run cargo hack check
run: ${{ matrix.command }}

fuzz-targets:
name: Fuzz targets (nightly)
runs-on: ubuntu-latest
needs: setup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fuzz-targets job doesn’t actually need the setup dependency, as it completely overrides the toolchain parameter with its own value.
We might consider removing this dependency to make clear the intent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this doesn’t use any outputs from setup. 👍

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

# Install nightly matching org pattern, pinned to v1.13.0 of the action.
- name: Install Rust nightly toolchain
id: install_rust
uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 # v1.13.0
with:
toolchain: ${{ inputs.rust-nightly-version }}
cache: true
cache-key: >
fuzz-${{ hashFiles('clarity/fuzz/Cargo.lock') }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe cache key is too narrow. If nightly version changes, we could get stale caches that fail to build because dependencies or the compiler version mismatch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps

fuzz-${{ inputs.rust-nightly-version }}-${{ hashFiles('clarity/fuzz/Cargo.lock') }}

or something like

fuzz-${{ inputs.rust-nightly-version }}-${{ runner.os }}-${{ hashFiles('clarity/fuzz/Cargo.lock') }}

We'll have to try.


- name: Build fuzz targets (compile-only)
run: |
cargo +${{ inputs.rust-nightly-version }} build \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use check here instead of build?
Since the objective is only to verify whether it compiles, this would be faster and more aligned with the purpose of the workflow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I always do cargo +nightly fuzz build but here check would be more efficient.

--manifest-path clarity/fuzz/Cargo.toml \
--bins \
--locked
Loading
Loading