---
name: Fuzzing v3rpc
on: [push, pull_request]
permissions: read-all
jobs:
  fuzzing:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
    env:
      TARGET_PATH: ./server/etcdserver/api/v3rpc
    steps:
      - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
      - id: goversion
        run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
      - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
        with:
          go-version: ${{ steps.goversion.outputs.goversion }}
      - run: |
          set -euo pipefail

          GOARCH=amd64 CPU=4 make fuzz
      - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
        if: failure()
        with:
          path: "${{env.TARGET_PATH}}/testdata/fuzz/**/*"
