name: CI

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

permissions:
  contents: read

jobs:
  Build:
    strategy:
      fail-fast: false
      matrix:
        # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
        ruby:
          # - head
          - '3.4'
          - '3.3'
          - '3.2'
          - '3.1'
          - '3.0'
          - '2.7'
        os:
          - ubuntu
          - macos
          - windows
        gemfile:
          - no_rails
          - rails_7.1
          - rails_7.2
          - rails_8
        exclude:
          - ruby: 2.7
            gemfile: rails_7.2
          - ruby: 3.0
            gemfile: rails_7.2
          - ruby: 2.7
            gemfile: rails_8
          - ruby: 3.0
            gemfile: rails_8
          - ruby: 3.1
            gemfile: rails_8
          - os: macos
            ruby: head
          - os: windows
            ruby: head
          - os: windows
            gemfile: rails_7.1
          - 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@v6
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true
      - run: bundle exec rake
