name: Main
on:
  push:
    branches:
      - main
      - master

  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  base:
    name: Ruby ${{ matrix.ruby }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        ruby:
          - "2.7"
          - "3.0"
          - "3.1"
          - "3.2"

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      # This setup is not compatible with the way Travis CI was
      # setup, so the cache will only work for the root folder.
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true

      - name: Rake
        run: bundle exec rake

      - uses: codecov/codecov-action@v3

  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      # This setup is not compatible with the way Travis CI was
      # setup, so the cache will only work for the root folder.
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.2"
          bundler-cache: true

      - name: standardrb
        run: bundle exec standardrb
