name: databases-nightly

on:
  schedule:
    - cron: '0 0 * * *'

jobs:
  mysql_9:
    runs-on: ubuntu-24.04

    services:
      mysql:
        image: mysql:9
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: yes
          MYSQL_DATABASE: laravel
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

    strategy:
      fail-fast: true

    name: MySQL 9

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

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.3
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr
          tools: composer:v2
          coverage: none

      - name: Set Framework version
        run: composer config version "12.x-dev"

      - name: Install dependencies
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 5
          max_attempts: 5
          command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

      - name: Execute tests
        run: vendor/bin/phpunit tests/Integration/Database
        env:
          DB_CONNECTION: mysql

  mariadb:
    runs-on: ubuntu-24.04
    continue-on-error: true

    services:
      mariadb:
        image: quay.io/mariadb-foundation/mariadb-devel:verylatest
        env:
          MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes
          MARIADB_DATABASE: laravel
        ports:
          - 3306:3306
        options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3

    strategy:
      fail-fast: true

    name: MariaDB Very Latest

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

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.3
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr
          tools: composer:v2
          coverage: none

      - name: Set Framework version
        run: composer config version "12.x-dev"

      - name: Install dependencies
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 5
          max_attempts: 5
          command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

      - name: Execute tests
        run: vendor/bin/phpunit tests/Integration/Database
        env:
          DB_CONNECTION: mariadb
