name: "Continuous Integration"

on:
  pull_request:
  push:
    branches:
      - '[0-9]+.[0-9]+.x'
      - 'refs/pull/*'
    tags:

jobs:
  matrix:
    name: Generate job matrix
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.matrix.outputs.matrix }}
    steps:
      - name: Gather CI configuration
        id: matrix
        uses: laminas/laminas-ci-matrix-action@v1

  qa:
    name: QA Checks
    needs: [matrix]
    runs-on: ${{ matrix.operatingSystem }}
    strategy:
      fail-fast: false
      matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
    steps:
      - name: ${{ matrix.name }}
        uses: laminas/laminas-continuous-integration-action@v1
        with:
          job: ${{ matrix.job }}
    services:
      mysql:
        image: mysql:5.7
        env:
          MYSQL_ROOT_PASSWORD: 'password'
          MYSQL_ROOT_HOST: '%'
          MYSQL_USER: 'gha'
          MYSQL_PASSWORD: 'password'
          MYSQL_DATABASE: 'laminasdb_test'
        options: >-
          --health-cmd="mysqladmin ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 3
        ports:
          - 3306
      postgres:
        image: postgres
        env:
          POSTGRES_USER: 'gha'
          POSTGRES_PASSWORD: 'password'
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 3
        ports:
          - 5432
      mssql:
        image: mcr.microsoft.com/mssql/server:2022-latest
        env:
          ACCEPT_EULA: 'Y'
          SA_PASSWORD: 'Password123'
        ports:
          - 1433
        options: >-
          --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Password123' -Q 'SELECT 1' || exit 1"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 3
          --health-start-period 10s
