name: RSpec CI
on:
  push:
    branches:
      - 'main'
      - '*-maintenance'
      - '*-dev'
  pull_request:
    branches:
      - '*'
env:
  RSPEC_CI: true
jobs:
  rubocop:
    name: Rubocop
    runs-on: 'ubuntu-20.04'
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.3'
      - run: script/update_rubygems_and_install_bundler
      - run: bundle install
      - run: bundle exec rubocop -c .rubocop.yml

  test:
    name: Ruby ${{ matrix.ruby }} ${{ matrix.name_extra || '' }}
    runs-on: ${{ matrix.os || 'ubuntu-20.04' }}
    strategy:
      matrix:
        ruby:
          - '3.4'
          - '3.3'
          - '3.2'
          - '3.1'
          - '3.0'
        env:
          -
            BRANCH: "main"
        include:
          - ruby: '3.3'
            name_extra: "against RSpec 3.13"
            env:
              BRANCH: "3-13-maintenance"
          - ruby: '3.2'
            name_extra: "against RSpec 3.13"
            env:
              BRANCH: "3-13-maintenance"
          - ruby: '3.1'
            name_extra: "against RSpec 3.13"
            env:
              BRANCH: "3-13-maintenance"
          - ruby: '3.0'
            name_extra: "against RSpec 3.13"
            env:
              BRANCH: "3-13-maintenance"
      fail-fast: false
    continue-on-error: ${{ matrix.allow_failure || endsWith(matrix.ruby, 'head') }}
    env: ${{ matrix.env }}
    steps:
      - uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
        with:
          bundler: ${{ matrix.bundler || 2 }}
          ruby-version: ${{ matrix.ruby }}
      - run: script/update_rubygems_and_install_bundler
      - run: bundle install --standalone
      - run: bundle binstubs --all
      - run: script/test_all
