|
| 1 | +# |
| 2 | +# Copyright (c) 2026 ZettaScale Technology |
| 3 | +# |
| 4 | +# This program and the accompanying materials are made available under the |
| 5 | +# terms of the Eclipse Public License 2.0 which is available at |
| 6 | +# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| 7 | +# which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| 8 | +# |
| 9 | +# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| 10 | +# |
| 11 | +# Contributors: |
| 12 | +# ZettaScale Zenoh Team, <zenoh@zettascale.tech> |
| 13 | +# |
| 14 | +name: Scheduled Fuzzing |
| 15 | + |
| 16 | +on: |
| 17 | + schedule: |
| 18 | + # Run the 1-hour campaign every day except Sunday. |
| 19 | + - cron: "0 0 * * 1-6" |
| 20 | + # Run the 5-hour campaign on Sunday instead of the daily run. |
| 21 | + - cron: "0 0 * * 0" |
| 22 | + workflow_dispatch: |
| 23 | + inputs: |
| 24 | + profile: |
| 25 | + type: choice |
| 26 | + description: Fuzzing duration profile |
| 27 | + required: true |
| 28 | + default: daily |
| 29 | + options: |
| 30 | + - daily |
| 31 | + - weekly |
| 32 | + |
| 33 | +env: |
| 34 | + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse |
| 35 | + NIGHTLY_TOOLCHAIN: nightly |
| 36 | + |
| 37 | +jobs: |
| 38 | + determine-profile: |
| 39 | + name: Determine fuzzing profile |
| 40 | + runs-on: ubuntu-latest |
| 41 | + outputs: |
| 42 | + label: ${{ steps.profile.outputs.label }} |
| 43 | + max_total_time: ${{ steps.profile.outputs.max_total_time }} |
| 44 | + steps: |
| 45 | + - name: Select duration profile |
| 46 | + id: profile |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 50 | + profile="${{ inputs.profile }}" |
| 51 | + elif [[ "${{ github.event.schedule }}" == "0 0 * * 0" ]]; then |
| 52 | + profile="weekly" |
| 53 | + else |
| 54 | + profile="daily" |
| 55 | + fi |
| 56 | +
|
| 57 | + if [[ "$profile" == "weekly" ]]; then |
| 58 | + echo "label=weekly" >> "$GITHUB_OUTPUT" |
| 59 | + echo "max_total_time=18000" >> "$GITHUB_OUTPUT" |
| 60 | + else |
| 61 | + echo "label=daily" >> "$GITHUB_OUTPUT" |
| 62 | + echo "max_total_time=3600" >> "$GITHUB_OUTPUT" |
| 63 | + fi |
| 64 | +
|
| 65 | + fuzz-codec: |
| 66 | + name: Codec fuzz (${{ needs.determine-profile.outputs.label }}) - ${{ matrix.target }} |
| 67 | + needs: determine-profile |
| 68 | + runs-on: ubuntu-latest |
| 69 | + timeout-minutes: 330 |
| 70 | + strategy: |
| 71 | + fail-fast: false |
| 72 | + matrix: |
| 73 | + target: |
| 74 | + - transport_message |
| 75 | + - network_message |
| 76 | + - frame |
| 77 | + - scouting_message |
| 78 | + steps: |
| 79 | + - name: Clone this repository |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Install latest Rust toolchain |
| 83 | + run: rustup toolchain install ${{ env.NIGHTLY_TOOLCHAIN }} |
| 84 | + |
| 85 | + - name: Install cargo-fuzz |
| 86 | + run: cargo +stable install --locked cargo-fuzz |
| 87 | + |
| 88 | + - name: Setup rust-cache |
| 89 | + uses: Swatinem/rust-cache@v2 |
| 90 | + with: |
| 91 | + cache-bin: false |
| 92 | + workspaces: | |
| 93 | + . -> target |
| 94 | + commons/zenoh-codec/fuzz -> commons/zenoh-codec/fuzz/target |
| 95 | +
|
| 96 | + - name: Generate zenoh-codec seed corpora |
| 97 | + run: cargo run --bin gen_all_corpora |
| 98 | + working-directory: commons/zenoh-codec/fuzz |
| 99 | + |
| 100 | + - name: Verify zenoh-codec seed corpora |
| 101 | + run: cargo run --bin verify_all_corpora |
| 102 | + working-directory: commons/zenoh-codec/fuzz |
| 103 | + |
| 104 | + - name: Run codec fuzz target |
| 105 | + run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} fuzz run ${{ matrix.target }} -- -max_total_time=${{ needs.determine-profile.outputs.max_total_time }} |
| 106 | + working-directory: commons/zenoh-codec/fuzz |
| 107 | + |
| 108 | + - name: Upload codec fuzz artifacts |
| 109 | + if: failure() |
| 110 | + uses: actions/upload-artifact@v4 |
| 111 | + with: |
| 112 | + name: fuzz-artifacts-codec-${{ needs.determine-profile.outputs.label }}-${{ matrix.target }} |
| 113 | + path: commons/zenoh-codec/fuzz/artifacts/${{ matrix.target }} |
| 114 | + if-no-files-found: ignore |
| 115 | + retention-days: 14 |
| 116 | + |
| 117 | + fuzz-protocol: |
| 118 | + name: Protocol fuzz (${{ needs.determine-profile.outputs.label }}) - endpoint_from_str |
| 119 | + needs: determine-profile |
| 120 | + runs-on: ubuntu-latest |
| 121 | + timeout-minutes: 330 |
| 122 | + steps: |
| 123 | + - name: Clone this repository |
| 124 | + uses: actions/checkout@v4 |
| 125 | + |
| 126 | + - name: Install latest Rust toolchain |
| 127 | + run: rustup toolchain install ${{ env.NIGHTLY_TOOLCHAIN }} |
| 128 | + |
| 129 | + - name: Install cargo-fuzz |
| 130 | + run: cargo +stable install --locked cargo-fuzz |
| 131 | + |
| 132 | + - name: Setup rust-cache |
| 133 | + uses: Swatinem/rust-cache@v2 |
| 134 | + with: |
| 135 | + cache-bin: false |
| 136 | + workspaces: | |
| 137 | + . -> target |
| 138 | + commons/zenoh-protocol/fuzz -> commons/zenoh-protocol/fuzz/target |
| 139 | +
|
| 140 | + - name: Generate endpoint_from_str seed corpus |
| 141 | + run: cargo run --bin gen_endpoint_corpus |
| 142 | + working-directory: commons/zenoh-protocol/fuzz |
| 143 | + |
| 144 | + - name: Verify endpoint_from_str seed corpus |
| 145 | + run: cargo run --bin verify_endpoint_corpus |
| 146 | + working-directory: commons/zenoh-protocol/fuzz |
| 147 | + |
| 148 | + - name: Run endpoint_from_str fuzz target |
| 149 | + run: cargo +${{ env.NIGHTLY_TOOLCHAIN }} fuzz run endpoint_from_str -- -max_total_time=${{ needs.determine-profile.outputs.max_total_time }} |
| 150 | + working-directory: commons/zenoh-protocol/fuzz |
| 151 | + |
| 152 | + - name: Upload protocol fuzz artifacts |
| 153 | + if: failure() |
| 154 | + uses: actions/upload-artifact@v4 |
| 155 | + with: |
| 156 | + name: fuzz-artifacts-protocol-${{ needs.determine-profile.outputs.label }}-endpoint_from_str |
| 157 | + path: commons/zenoh-protocol/fuzz/artifacts/endpoint_from_str |
| 158 | + if-no-files-found: ignore |
| 159 | + retention-days: 14 |
0 commit comments