# Testing the code base against a specific Meilisearch feature
name: Meilisearch Prototype Beta tests

# Will only run for PRs and pushes to *-beta
on:
  push:
    branches: ['meilisearch-*-beta']
  pull_request:
    branches: ['meilisearch-*-beta']

jobs:
  meilisearch-version:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v5

      - name: Grep docker beta version of Meilisearch
        id: grep-step
        run: |
          MEILISEARCH_VERSION=$(sh .github/scripts/beta-docker-version.sh)
          echo $MEILISEARCH_VERSION
          echo "version=$MEILISEARCH_VERSION" >> $GITHUB_OUTPUT
    outputs:
      version: ${{ steps.grep-step.outputs.version }}

  tests:
    runs-on: ubuntu-latest
    needs: ['meilisearch-version']
    name: integration-tests-against-rc (PHP ${{ matrix.php-version }})
    services:
      meilisearch:
        image: getmeili/meilisearch:${{ needs.meilisearch-version.outputs.version }}
        ports:
          - '7700:7700'
        env:
          MEILI_MASTER_KEY: masterKey
          MEILI_NO_ANALYTICS: true
    strategy:
      matrix:
        php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

    steps:
      - name: Checkout code
        uses: actions/checkout@v5

      - name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-versions }}

      - name: Validate composer.json and composer.lock
        run: composer validate

      - name: Install dependencies
        uses: ramsey/composer-install@v3

      - name: Run test suite
        run: sh scripts/tests.sh
