name: Test ORM integrations

on:
  workflow_dispatch:
  repository_dispatch:
    types: [ test-orm-integrations ]

jobs:
  orm_integrations_job:
    runs-on: ubuntu-22.04
    timeout-minutes: 30
    name: Run tests
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Copy go package
        run: cp -r ./go ./integration-tests/go
      - name: Test ORM integrations
        uses: ./.github/actions/orm-tests
      - name: Configure AWS Credentials
        if: ${{ failure() }}
        uses: aws-actions/configure-aws-credentials@v2.2.0
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-west-2
      - name: Send Email
        if: ${{ failure() }}
        uses: ./.github/actions/ses-email-action
        with:
          template: 'OrmIntegrationFailureTemplate'
          region: us-west-2
          version: ${{ github.ref }}
          toAddresses: '["jennifer@dolthub.com", "tim@dolthub.com"]'
          workflowURL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
