name: bundler

on:
  pull_request:

  push:
    branches:
      - 3.5

concurrency:
  group: ci-${{ github.ref }}-${{ github.workflow }}
  cancel-in-progress: true

permissions:  # added using https://github.com/step-security/secure-workflows
  contents: read

defaults:
  run:
    shell: bash

jobs:
  bundler:
    name: Bundler ${{ matrix.bundler.name }} on ${{ matrix.os.name }} (${{ matrix.ruby.name }})
    runs-on: ${{ matrix.os.value }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - { name: Ubuntu, value: ubuntu-24.04 }

        ruby:
          - { name: ruby-3.0, value: 3.0.7 }
          - { name: ruby-3.1, value: 3.1.6 }
          - { name: ruby-3.2, value: 3.2.6 }
          - { name: ruby-3.3, value: 3.3.5 }

        bundler:
          - { name: 2, value: '' }
          - { name: 3, value: 3.0.0 }

        include:
          - { os: { name: macOS, value: macos-14 }, bundler: { name: 2, value: '' }, ruby: { name: ruby-3.0, value: 3.0.7 }, timeout: 90 }
          - { os: { name: macOS, value: macos-14 }, bundler: { name: 2, value: '' }, ruby: { name: ruby-3.1, value: 3.1.6 }, timeout: 90 }
          - { os: { name: macOS, value: macos-14 }, bundler: { name: 2, value: '' }, ruby: { name: ruby-3.2, value: 3.2.6 }, timeout: 90 }
          - { os: { name: macOS, value: macos-14 }, bundler: { name: 2, value: '' }, ruby: { name: ruby-3.3, value: 3.3.5 }, timeout: 90 }

          - { os: { name: Windows, value: windows-2022 }, bundler: { name: 2, value: '' }, ruby: { name: ruby-3.0, value: 3.0.7 }, timeout: 150 }
          - { os: { name: Windows, value: windows-2022 }, bundler: { name: 2, value: '' }, ruby: { name: ruby-3.1, value: 3.1.6 }, timeout: 150 }
          - { os: { name: Windows, value: windows-2022 }, bundler: { name: 2, value: '' }, ruby: { name: ruby-3.2, value: 3.2.6 }, timeout: 150 }
          - { os: { name: Windows, value: windows-2022 }, bundler: { name: 2, value: '' }, ruby: { name: ruby-3.3, value: 3.3.5 }, timeout: 150 }

    env:
      RGV: ..
      RUBYOPT: --disable-gems
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
      - name: Setup ruby
        uses: ruby/setup-ruby@7d3497fd78c07c0d84ebafa58d8dac60cd1f0763 # v1.199.0
        with:
          ruby-version: ${{ matrix.ruby.value }}
          bundler: none
      - name: Install graphviz (Ubuntu)
        run: sudo apt-get install graphviz -y
        if: matrix.bundler.value == '' && matrix.os.name == 'Ubuntu'
      - name: Replace version
        run: BUNDLER_SPEC_SUB_VERSION=${{ matrix.bundler.value }} bin/rake override_version
        if: matrix.bundler.value != ''
      - name: Prepare dependencies
        run: |
          bin/rake spec:parallel_deps
      - name: Run Test
        run: |
          bin/parallel_rspec
        working-directory: ./bundler
    timeout-minutes: ${{ matrix.timeout || 60 }}
