name: test
on:
  push:
    branches:
      - main
  pull_request:
    types:
      - opened
      - synchronize
      - reopened
jobs:
  test:
    name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }}'
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        ruby: [2.6, 2.7, 3.0, jruby-9.2]
        rails: [5.2.x, 6.0.x, 6.1.x, rails-edge]
    steps:
      - uses: actions/checkout@v2
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
      - uses: actions/cache@v2
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: ${{ runner.os }}-gems-
      - name: bundle install --gemfile=test/gemfiles/Gemfile.rails-${{matrix.rails}}.x
        run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
      - name: rake test
        run: bundle exec rake test submodules
        env:
          RUBYOPT: "--enable-frozen-string-literal"
