name: Verify Generated Hook Headers

on:
  push:
  pull_request:

jobs:
  verify-generated-headers:
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: hook/error.h
            generator: ./hook/generate_error.sh
          - target: hook/extern.h
            generator: ./hook/generate_extern.sh
          - target: hook/sfcodes.h
            generator: bash ./hook/generate_sfcodes.sh
          - target: hook/tts.h
            generator: ./hook/generate_tts.sh
    runs-on: ubuntu-latest
    name: ${{ matrix.target }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Verify ${{ matrix.target }}
        run: |
          set -euo pipefail
          chmod +x hook/generate_*.sh || true

          tmp=$(mktemp)
          trap 'rm -f "$tmp"' EXIT

          ${{ matrix.generator }} > "$tmp"
          diff -u ${{ matrix.target }} "$tmp"
