|
| 1 | +name: CI |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - dev |
| 12 | + schedule: |
| 13 | + - cron: '0 2 * * *' |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +env: |
| 17 | + CARGO_INCREMENTAL: 0 |
| 18 | + CARGO_NET_GIT_FETCH_WITH_CLI: true |
| 19 | + CARGO_NET_RETRY: 10 |
| 20 | + CARGO_TERM_COLOR: always |
| 21 | + RUST_BACKTRACE: 1 |
| 22 | + RUSTDOCFLAGS: -D warnings |
| 23 | + RUSTFLAGS: -D warnings |
| 24 | + RUSTUP_MAX_RETRIES: 10 |
| 25 | + |
| 26 | +defaults: |
| 27 | + run: |
| 28 | + shell: bash --noprofile --norc -CeEuxo pipefail {0} |
| 29 | + |
| 30 | +concurrency: |
| 31 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} |
| 32 | + cancel-in-progress: true |
| 33 | + |
| 34 | +jobs: |
| 35 | + miri: |
| 36 | + uses: taiki-e/github-actions/.github/workflows/miri.yml@main |
| 37 | + with: |
| 38 | + # NB: sync with test job's --exclude option |
| 39 | + args: --exclude parse-dockerfile-internal-codegen |
| 40 | + msrv: |
| 41 | + uses: taiki-e/github-actions/.github/workflows/msrv.yml@main |
| 42 | + release-dry-run: |
| 43 | + uses: taiki-e/github-actions/.github/workflows/release-dry-run.yml@main |
| 44 | + test: |
| 45 | + uses: taiki-e/github-actions/.github/workflows/test.yml@main |
| 46 | + with: |
| 47 | + # NB: sync with miri job's --exclude option |
| 48 | + test-args: --exclude parse-dockerfile-internal-codegen |
| 49 | + build-args: --lib |
| 50 | + no-std: false |
| 51 | + tidy: |
| 52 | + uses: taiki-e/github-actions/.github/workflows/tidy.yml@main |
| 53 | + permissions: |
| 54 | + contents: read |
| 55 | + pull-requests: write # for gh pr edit --add-assignee |
| 56 | + repository-projects: read # for gh pr edit --add-assignee |
| 57 | + secrets: inherit |
| 58 | + |
| 59 | + fuzz: |
| 60 | + env: |
| 61 | + FUZZ_MAX_TOTAL_TIME: 60 # 1 minute |
| 62 | + runs-on: ubuntu-latest |
| 63 | + timeout-minutes: 60 |
| 64 | + steps: |
| 65 | + - uses: taiki-e/checkout-action@v1 |
| 66 | + - uses: taiki-e/github-actions/install-rust@nightly |
| 67 | + - run: sudo apt-get -o Acquire::Retries=10 -qq update && sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends binutils-dev libunwind8-dev |
| 68 | + - uses: taiki-e/cache-cargo-install-action@v2 |
| 69 | + with: |
| 70 | + tool: cargo-fuzz |
| 71 | + # We cannot use cache for cargo-afl because afl.rs requires the cargo-afl binary and afl library to be built with the same compiler version. |
| 72 | + - run: cargo install cargo-afl --debug --locked |
| 73 | + - uses: taiki-e/cache-cargo-install-action@v2 |
| 74 | + with: |
| 75 | + # TODO: Pass --no-default-features |
| 76 | + tool: honggfuzz |
| 77 | + - run: cargo fuzz build --features libfuzzer |
| 78 | + - run: cargo afl build --release --features afl |
| 79 | + working-directory: fuzz |
| 80 | + - run: | |
| 81 | + HFUZZ_BUILD_ARGS="--features honggfuzz" \ |
| 82 | + RUSTFLAGS="${RUSTFLAGS:-} -Z sanitizer=address" \ |
| 83 | + cargo hfuzz build |
| 84 | + working-directory: fuzz |
| 85 | + # On scheduled job, run fuzzer $FUZZ_MAX_TOTAL_TIME seconds per target. |
| 86 | + # TODO: This is currently skipped for libfuzzer due to https://github.com/rust-fuzz/cargo-fuzz/issues/270. |
| 87 | + # TODO: Honggfuzz |
| 88 | + - name: Cache AFL++ output |
| 89 | + uses: actions/cache@v4 |
| 90 | + with: |
| 91 | + path: fuzz/out |
| 92 | + key: afl-out-${{ github.run_id }} |
| 93 | + restore-keys: afl-out- |
| 94 | + if: github.event_name == 'schedule' |
| 95 | + - name: Fuzzing with AFL++ |
| 96 | + run: | |
| 97 | + sudo tee -- /proc/sys/kernel/core_pattern >/dev/null <<<core |
| 98 | + # shellcheck disable=SC2010 |
| 99 | + for target in $(ls | grep -E '\.rs$' | sed -E 's/\.rs$//'); do |
| 100 | + cargo afl fuzz -i "seeds/${target}" -o "out/${target}" -V "${FUZZ_MAX_TOTAL_TIME}" "target/release/${target}" |
| 101 | + rmdir -- "out/${target}/default/crashes" 2>/dev/null || true |
| 102 | + rmdir -- "out/${target}/default/hangs" 2>/dev/null || true |
| 103 | + if [[ -d "out/${target}/default/crashes" ]] || [[ -d "out/${target}/default/hangs" ]]; then |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | + done |
| 107 | + working-directory: fuzz |
| 108 | + if: github.event_name == 'schedule' |
| 109 | + - name: Archive artifacts |
| 110 | + run: | |
| 111 | + if [[ -d out ]]; then |
| 112 | + tar acvf ../afl-artifacts.tar.gz out |
| 113 | + fi |
| 114 | + working-directory: fuzz |
| 115 | + if: failure() && github.event_name == 'schedule' |
| 116 | + - name: Upload artifacts |
| 117 | + uses: actions/upload-artifact@v4 |
| 118 | + with: |
| 119 | + name: fuzz-artifacts |
| 120 | + path: afl-artifacts.tar.gz |
| 121 | + if: failure() && github.event_name == 'schedule' |
0 commit comments