name: Continuous Integration

on:
  push:
    branches:
      - main
      - actions-*
    tags:
      - v*
  pull_request:
    branches-ignore:
      - actions-*
  workflow_dispatch:

env:
  BUNDLE_CLEAN: "true"
  BUNDLE_PATH: vendor/bundle
  BUNDLE_JOBS: 3
  BUNDLE_RETRY: 3

jobs:
  build:
    name: build ruby-${{ matrix.ruby }} ${{ matrix.appraisal }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - ruby: "ruby"
            standardrb: true
            yard: true
          - ruby: "jruby"
          - ruby: "3.4"
          - ruby: "3.3"
          - ruby: "3.2"
          - ruby: "3.1"
          - ruby: "3.0"
          - ruby: "2.7"
    steps:
      - uses: actions/checkout@v6
      - name: Set up Ruby ${{ matrix.ruby }}
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: "${{ matrix.ruby }}"
      - name: Setup bundler
        if: matrix.bundler != ''
        run: |
          gem uninstall bundler --all
          gem install bundler --no-document --version ${{ matrix.bundler }}
      - name: Set Appraisal bundle
        if: matrix.appraisal != ''
        run: |
          echo "using gemfile gemfiles/${{ matrix.appraisal }}.gemfile"
          bundle config set gemfile "gemfiles/${{ matrix.appraisal }}.gemfile"
      - name: Install gems
        run: |
          bundle install
      - name: Run Tests
        run: bundle exec rake
      - name: standardrb
        if:   matrix.standardrb == true
        run:  bundle exec standardrb
      - name: yard
        if: matrix.yard == true
        run:  bundle exec yard --fail-on-warning
