Skip to content

Commit 682d9c5

Browse files
authored
fuzzing.yml: Use prebuilt for faster setup (#10498)
1 parent 368230e commit 682d9c5

1 file changed

Lines changed: 21 additions & 32 deletions

File tree

.github/workflows/fuzzing.yml

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Fuzzing
22

3-
# spell-checker:ignore fuzzer dtolnay Swatinem
3+
# spell-checker:ignore (people) dtolnay Swatinem taiki-e
4+
# spell-checker:ignore (misc) fuzzer
45

56
on:
67
pull_request:
@@ -19,16 +20,13 @@ concurrency:
1920
jobs:
2021
uufuzz-examples:
2122
name: Build and test uufuzz examples
23+
env:
24+
CARGO_INCREMENTAL: 0
2225
runs-on: ubuntu-latest
2326
steps:
2427
- uses: actions/checkout@v6
2528
with:
2629
persist-credentials: false
27-
- uses: dtolnay/rust-toolchain@stable
28-
- uses: Swatinem/rust-cache@v2
29-
with:
30-
shared-key: "uufuzz-cache-key"
31-
cache-directories: "fuzz/target"
3230
- name: Build uufuzz library
3331
run: |
3432
cd fuzz/uufuzz
@@ -59,15 +57,16 @@ jobs:
5957
with:
6058
persist-credentials: false
6159
- name: Install `cargo-fuzz`
62-
run: |
63-
echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}" # Use -Z
64-
cargo install cargo-fuzz --locked
65-
- uses: Swatinem/rust-cache@v2
60+
uses: taiki-e/install-action@v2
6661
with:
67-
shared-key: "cargo-fuzz-cache-key"
68-
cache-directories: "fuzz/target"
62+
tool: cargo-fuzz
63+
- name: Emulate a nightly toolchain
64+
run: |
65+
echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}"
6966
- name: Run `cargo-fuzz build`
70-
run: cargo fuzz build
67+
# Force the correct target
68+
# https://github.com/rust-fuzz/cargo-fuzz/issues/398
69+
run: cargo fuzz build --target $(rustc --print host-tuple)
7170

7271
fuzz-run:
7372
needs: fuzz-build
@@ -76,6 +75,7 @@ jobs:
7675
timeout-minutes: 5
7776
env:
7877
RUN_FOR: 60
78+
CARGO_INCREMENTAL: 0
7979
strategy:
8080
matrix:
8181
test-target:
@@ -104,27 +104,22 @@ jobs:
104104
with:
105105
persist-credentials: false
106106
- name: Install `cargo-fuzz`
107-
run: |
108-
echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}" # Use nightly
109-
cargo install cargo-fuzz --locked
110-
- uses: Swatinem/rust-cache@v2
107+
uses: taiki-e/install-action@v2
111108
with:
112-
shared-key: "cargo-fuzz-cache-key"
113-
cache-directories: "fuzz/target"
114-
- name: Restore Cached Corpus
115-
uses: actions/cache/restore@v5
116-
with:
117-
key: corpus-cache-${{ matrix.test-target.name }}
118-
path: |
119-
fuzz/corpus/${{ matrix.test-target.name }}
109+
tool: cargo-fuzz
110+
- name: Emulate a nightly toolchain
111+
run: |
112+
echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}"
120113
- name: Run ${{ matrix.test-target.name }} for XX seconds
121114
id: run_fuzzer
122115
shell: bash
123116
continue-on-error: ${{ !matrix.test-target.should_pass }}
124117
run: |
125118
mkdir -p fuzz/stats
126119
STATS_FILE="fuzz/stats/${{ matrix.test-target.name }}.txt"
127-
cargo fuzz run ${{ matrix.test-target.name }} -- -max_total_time=${{ env.RUN_FOR }} -timeout=${{ env.RUN_FOR }} -detect_leaks=0 -print_final_stats=1 2>&1 | tee "$STATS_FILE"
120+
# Force the correct target
121+
# https://github.com/rust-fuzz/cargo-fuzz/issues/398
122+
cargo fuzz run --target $(rustc --print host-tuple) ${{ matrix.test-target.name }} -- -max_total_time=${{ env.RUN_FOR }} -timeout=${{ env.RUN_FOR }} -detect_leaks=0 -print_final_stats=1 2>&1 | tee "$STATS_FILE"
128123
129124
# Extract key stats from the output
130125
if grep -q "stat::number_of_executed_units" "$STATS_FILE"; then
@@ -193,12 +188,6 @@ jobs:
193188
fi
194189
195190
echo "" >> $GITHUB_STEP_SUMMARY
196-
- name: Save Corpus Cache
197-
uses: actions/cache/save@v5
198-
with:
199-
key: corpus-cache-${{ matrix.test-target.name }}
200-
path: |
201-
fuzz/corpus/${{ matrix.test-target.name }}
202191
- name: Upload Stats
203192
uses: actions/upload-artifact@v6
204193
with:

0 commit comments

Comments
 (0)