---
name: Test

on:
  pull_request: {}
  push:
    branches:
      - master

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-24.04
    strategy:
      fail-fast: false
      matrix:
        ruby:
          - "2.4"
          - "2.5"
          - "2.6"
          - "2.7"
          - "3.0"
          - "3.1"
          - "3.2"
          - "3.3"
          - "3.4"
          - "4.0"
    steps:
      - uses: actions/checkout@v2
      - name: Install Ruby ${{ matrix.ruby }}
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true
      - name: Run tests
        run: bundle exec rake spec
      - name: Verify gem builds
        run: gem build *.gemspec

  tests:
    if: always()
    needs:
      - test
    runs-on: ubuntu-24.04
    name: Test suite
    steps:
      - name: Decide whether the needed jobs succeeded or failed
        uses: re-actors/alls-green@release/v1
        with:
          jobs: ${{ toJSON(needs) }}
