brunoocasali/devise_last_seen

View on GitHub
.github/workflows/gem.yml

Summary

Maintainability
Test Coverage
name: ruby gem
on: [push]

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        gemfile:
          - Gemfile
          - gemfiles/Gemfile-rails-6-1
          - gemfiles/Gemfile-rails-7-0
        ruby:
          - 2.7
          - 3.0
          - 3.1
          - 3.2
    runs-on: ubuntu-latest
    env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
      BUNDLE_GEMFILE: ${{ matrix.gemfile }}
      CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
    steps:
      - uses: actions/checkout@v3

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true # runs bundle install and caches installed gems automatically
          bundler: ${{ env.BUNDLER_VERSION || 'latest' }}

      - name: Run rubocop
        run: bundle exec rubocop # runs only in older ruby version
        if: matrix.ruby == '2.7' && matrix.gemfile == 'Gemfile'

      - name: Run tests
        run: bundle exec rspec
        # not needed because it will run using the codeclimate action
        if: matrix.ruby != '3.0' && matrix.gemfile != 'Gemfile'


      - name: Publish code coverage
        uses: paambaati/codeclimate-action@v4.0.0
        with:
          coverageCommand: bundle exec rspec
        if: matrix.ruby == '3.0' && matrix.gemfile == 'Gemfile'