name: Benchmark SQL Correctness

on:
  repository_dispatch:
    types: [ release-dolt ]
  workflow_dispatch:
    inputs:
      version:
        description: 'SemVer format release tag, i.e. 0.24.5'
        required: true
        default: ''
      email:
        description: 'Email address to receive results'
        required: true
        default: ''

jobs:
  set-version-actor:
    name: Set Version and Actor
    runs-on: ubuntu-22.04
    outputs:
      version: ${{ steps.set-vars.outputs.version }}
      actor: ${{ steps.set-vars.outputs.actor }}
    steps:
      - name: Set variables
        id: set-vars
        run: |
          echo "version=$VERSION" >> $GITHUB_OUTPUT
          echo "actor=$ACTOR" >> $GITHUB_OUTPUT
        env:
          VERSION: ${{ github.event.inputs.version || github.event.client_payload.version }}
          ACTOR: ${{ github.event.client_payload.actor || github.actor }}

  correctness:
    runs-on: ubuntu-22.04
    needs: set-version-actor
    name: Trigger SQL Correctness K8s Workflow
    steps:
      - uses: peter-evans/repository-dispatch@v2.0.0
        with:
          token: ${{ secrets.REPO_ACCESS_TOKEN }}
          event-type: sql-correctness
          client-payload: '{"version": "${{ needs.set-version-actor.outputs.version }}", "mode": "release", "actor": "${{ needs.set-version-actor.outputs.actor }}", "actor_email": "${{ needs.set-version-actor.outputs.actor_email }}", "template_script": "./.github/scripts/sql-correctness/get-dolt-correctness-job-json.sh"}'
