Files
IronRDP/.github/workflows/fuzz.yml
Marc-André Moreau 649ac65d0c ci: keep Rust cache keys stable and cancel superseded runs (#2268)
Swatinem/rust-cache hashes every installed toolchain into its key,
including the runner's preinstalled stable. Runner images currently ship
either stable 1.99.0 or 1.99.1, so the key splits while master saves
only one variant: macOS Checks found no cache in about half of pull
request runs and compiled all 1164 crates (about 22 minutes instead of
11), and Linux restored a stale cache. Uninstalling every toolchain
except the one pinned in rust-toolchain.toml before the cache step makes
the key depend only on the pinned toolchain and the lockfiles. The fuzz,
agentic RDP and release binary workflows get the same step; the release
workflow inlines it because it checks out the release tag, which may
predate the shared action.

Stacked pull requests receive two `synchronize` events per push (base
and head branch), which started two full CI runs on the same commit, and
a new push left the previous run going to completion. CI now keeps only
the latest run per pull request.

The build jobs no longer wait for the formatting check, which only
delayed them; `Success` still requires it.

The cache keys change, so pull request runs build without a cache until
the first master run after merge saves the new caches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:19:22 -04:00

208 lines
5.9 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Fuzz
on:
workflow_dispatch:
schedule:
- cron: '12 3 * * 0' # At 03:12 AM UTC on Sunday.
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: short
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
jobs:
corpus-download:
name: Download corpus
runs-on: ubuntu-latest
env:
AZURE_STORAGE_KEY: ${{ secrets.CORPUS_AZURE_STORAGE_KEY }}
steps:
- uses: actions/checkout@v6
- name: Download fuzzing corpus
run: cargo xtask fuzz corpus-fetch -v
- name: Save corpus
uses: actions/cache/save@v5
with:
path: |
./fuzz/corpus
./fuzz/artifacts
key: fuzz-corpus-${{ github.run_id }}
fuzz-setup:
name: Fuzz matrix setup
needs: [corpus-download]
runs-on: ubuntu-latest
outputs:
fuzz-matrix: ${{ steps.setup-matrix.outputs.fuzz-matrix }}
steps:
- uses: actions/checkout@v6
- name: Prune Rust toolchains
uses: ./.github/actions/prune-rust-toolchains
- name: Rust cache
uses: Swatinem/rust-cache@v2.9.1
- name: Setup matrix
id: setup-matrix
run: |
MATRIX="$(cargo xtask fuzz list --format github-matrix)"
echo "fuzz-matrix=$MATRIX" >> "$GITHUB_OUTPUT"
fuzz:
name: Fuzzing ${{ matrix.target }}
needs: [corpus-download, fuzz-setup]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.fuzz-setup.outputs.fuzz-matrix) }}
steps:
- uses: actions/checkout@v6
- name: Download corpus
uses: actions/cache/restore@v5
with:
fail-on-cache-miss: true
path: |
./fuzz/corpus
./fuzz/artifacts
key: fuzz-corpus-${{ github.run_id }}
- name: Print corpus
run: |
tree ./fuzz/corpus
tree ./fuzz/artifacts
- name: Prune Rust toolchains
uses: ./.github/actions/prune-rust-toolchains
- name: Rust cache
uses: Swatinem/rust-cache@v2.9.1
with:
workspaces: fuzz -> target
- name: Binary cache
uses: actions/cache@v5
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
- name: Prepare runner
run: cargo xtask fuzz install -v
- name: Fuzz
run: cargo xtask fuzz run --duration 1000 --target ${{ matrix.target }} -v
- name: Minify fuzzing corpus
if: ${{ always() && !cancelled() }}
run: cargo xtask fuzz corpus-min --target ${{ matrix.target }} -v
# Use GitHub artifacts instead of cache for the updated corpus
# because same cache can’t be used by multiple jobs at the same time.
# Also, we can’t dynamically create a unique cache keys for all
# the targets, because then we can’t easily retrieve this cache
# without hardcoding a step for each one. It’s not good for maintenance.
- name: Prepare minified corpus upload
# We want to upload artifacts even if fuzzing "fails" (so we can retrieve the artifact causing the crash)
if: ${{ always() && !cancelled() }}
run: |
mkdir ${{ runner.temp }}/corpus/
cp -r ./fuzz/corpus/${{ matrix.target }} ${{ runner.temp }}/corpus
mkdir ${{ runner.temp }}/artifacts/
cp -r ./fuzz/artifacts/${{ matrix.target }} ${{ runner.temp }}/artifacts
- name: Upload minified corpus
if: ${{ always() && !cancelled() }}
uses: actions/upload-artifact@v7
with:
retention-days: 7
name: minified-corpus-${{ matrix.target }}
path: |
${{ runner.temp }}/corpus
${{ runner.temp }}/artifacts
corpus-merge:
name: Corpus merge artifacts
if: ${{ always() && !cancelled() }}
needs: [fuzz]
runs-on: ubuntu-latest
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v7
with:
name: minified-corpus
pattern: minified-corpus-*
delete-merged: true
corpus-upload:
name: Upload corpus
if: ${{ always() && !cancelled() }}
needs: [corpus-merge]
runs-on: ubuntu-latest
env:
AZURE_STORAGE_KEY: ${{ secrets.CORPUS_AZURE_STORAGE_KEY }}
steps:
- uses: actions/checkout@v6
- name: Download updated corpus
uses: actions/download-artifact@v8
with:
name: minified-corpus
path: ./fuzz/
- name: Print corpus
run: |
tree ./fuzz/corpus
tree ./fuzz/artifacts
- name: Upload fuzzing corpus
run: cargo xtask fuzz corpus-push -v
- name: Clean corpus cache
run: |
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/caches?key=fuzz-corpus-${{ github.run_id }}"
notify:
name: Notify failure
if: ${{ always() && contains(needs.*.result, 'failure') && github.event_name == 'schedule' }}
needs: [fuzz]
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_ARCHITECTURE }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
steps:
- name: Send slack notification
id: slack
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*${{ github.repository }}* :warning: \n Fuzz workflow for *${{ github.repository }}* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|found a bug>"
}
}
]
}