name: CI

on:
  push:
    branches:
      - '*'
  pull_request:

permissions:
  contents: read

jobs:
  Build:
    strategy:
      fail-fast: false
      matrix:
        ruby:
          # - head
          - '4.0'
          - '3.4'
          - '3.3'
          - '3.2'
        os:
          - ubuntu
          - macos
          - windows
        gemfile:
          - no_rails
          - rails_7.2
          - rails_8
        exclude:
          - os: macos
            ruby: head
          - os: windows
            ruby: head
          - os: windows
            gemfile: rails_7.2
        include:
          - ruby: 'truffleruby'
            gemfile: no_rails
            os: ubuntu
          # no longer supported or until min stack size issue can be resolved
          # - ruby: 'ucrt'
          #   gemfile: no_rails
          #   os: windows

    env:
      BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
      MAKE: make -j 2
    runs-on: ${{ matrix.os }}-latest
    continue-on-error: ${{ matrix.ruby == 'head'}}
    name: Ruby ${{ matrix.ruby }} (${{ matrix.os }}${{ matrix.gemfile != 'no_rails' && ', ' || '' }}${{ matrix.gemfile != 'no_rails' && matrix.gemfile || '' }})
    steps:
      - uses: actions/checkout@v7
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true
      - run: bundle exec rake
