on: [ push, pull_request ]

jobs:
  ruby-versions:
    uses: ruby/actions/.github/workflows/ruby_versions.yml@master
    with:
      engine: cruby
      min_version: 3.1
  test:
    needs: ruby-versions
    name: >-
      Test (${{ matrix.ruby-version }} / ${{ matrix.os }} / TEST_SYMLINK: ${{ matrix.TEST_SYMLINK }})
    strategy:
      fail-fast: false
      matrix:
        ruby-version: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
        os: [ ubuntu-latest, macos-latest, windows-latest ]
        TEST_SYMLINK: [ yes, no ]
        include:
          - ruby-version: "3.3"
            os: "ubuntu-latest"
            TEST_SYMLINK: yes
            rubyopt: "--enable-frozen-string-literal"
    runs-on: ${{ matrix.os }}
    env:
      TEST_SYMLINK: ${{ matrix.TEST_SYMLINK }}
    continue-on-error: ${{ matrix.ruby-version == 'head' }}
    steps:
      - uses: actions/checkout@v5
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby-version }}
          bundler-cache: true
      - name: Run before_script
        run: |
          bundle exec rake before_script
      - name: Run the test suite
        run: |
          bundle exec rake RUBYOPT="${{ matrix.rubyopt }}"
      - name: Run after_script
        run: |
          bundle exec rake after_script
