okid 0.23.0

A library for generating double clickable ids
name: Fuzzing

on:
  push:
    branches: ["main"]
  pull_request:
    branches: ["main"]
  schedule:
    # Run fuzzing daily at 2 AM UTC
    - cron: "0 2 * * *"

env:
  CARGO_TERM_COLOR: always

jobs:
  fuzz:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        target:
          - fuzz_target_1

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust nightly
        uses: dtolnay/rust-toolchain@nightly

      - name: Install cargo-fuzz
        run: cargo install cargo-fuzz

      - name: Cache fuzz corpus
        uses: actions/cache@v4
        with:
          path: fuzz/corpus
          key: fuzz-corpus-${{ matrix.target }}-${{ github.sha }}
          restore-keys: |
            fuzz-corpus-${{ matrix.target }}-

      - name: Run fuzzer
        run: |
          # Run fuzzer for 5 minutes on CI
          timeout 300 cargo +nightly fuzz run ${{ matrix.target }} -- -max_total_time=300 || true
        continue-on-error: true

      - name: Check for crashes
        run: |
          if [ -d "fuzz/artifacts/${{ matrix.target }}" ] && [ "$(ls -A fuzz/artifacts/${{ matrix.target }})" ]; then
            echo "Fuzzing found crashes!"
            ls -la fuzz/artifacts/${{ matrix.target }}/
            exit 1
          fi

      - name: Upload artifacts on crash
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: fuzz-artifacts-${{ matrix.target }}
          path: fuzz/artifacts/${{ matrix.target }}/