name: build
on: [push, pull_request]
jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        include:
          - ruby: "4.0"
            gemfile: Gemfile
          - ruby: 3.4
            gemfile: gemfiles/activerecord80.gemfile
          - ruby: 3.3
            gemfile: gemfiles/activerecord72.gemfile
    runs-on: ubuntu-latest
    env:
      BUNDLE_GEMFILE: ${{ matrix.gemfile }}
    services:
      mariadb:
        image: mariadb:11.8
        env:
          MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 1
          MARIADB_DATABASE: neighbor_test
        ports:
          - 3307:3306
      mysql:
        image: mysql:9.7
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: 1
          MYSQL_DATABASE: neighbor_test
        ports:
          - 3306:3306
    steps:
      - uses: actions/checkout@v6
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true
      - uses: ankane/setup-postgres@v1
        with:
          database: neighbor_test
          dev-files: true
      - run: |
          cd /tmp
          git clone --branch v0.8.2 https://github.com/pgvector/pgvector.git
          cd pgvector
          make
          sudo make install
      - run: bundle exec rake test
      - run: TEST_TRILOGY=1 bundle exec rake test:mariadb
      - run: TEST_TRILOGY=1 bundle exec rake test:mysql
