rootstrap/exception_hunter

View on GitHub
.github/workflows/config.yml

Summary

Maintainability
Test Coverage
name: Rails tests

on: [pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        ruby-version: [2.6, 2.7, 3.0]
        rails-version: [5_2, 6_0, 6_1]
        exclude:
          - rails-version: 5_2
            ruby-version: 3.0
      fail-fast: false

    # Service containers to run with `runner-job`
    services:
      postgres:
        image: postgres:11
        ports:
          - 5432:5432
        env:
          POSTGRES_PASSWORD: postgres
          POSTGRES_USER: postgres
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

    steps:
      - uses: actions/checkout@v2

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby-version }}

      - name: Copy Gemfile
        run: yes | cp -rf Gemfile_$RAILS_VERSION Gemfile
        env:
          RAILS_VERSION: ${{ matrix.rails-version }}

      - name: Copy Application.rb
        run: yes | cp -rf spec/dummy/config/application_$RAILS_VERSION.rb spec/dummy/config/application.rb
        env:
          RAILS_VERSION: ${{ matrix.rails-version }}


      - name: Install PostgreSQL 11 client
        run: |
          sudo apt-get -yqq install libpq-dev

      - name: Bundle install
        run: |
          gem install bundler
          bundle update --jobs 4 --retry 3

      - name: Setup Database
        env:
          PGHOST: localhost
          PGUSER: postgres
          PGPASSWORD: postgres
          RAILS_ENV: test
          RAILS_VERSION: ${{ matrix.rails-version }}
        run: |
          bundle exec rails db:setup

      - name: CodeClimate
        run: |
          curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
          chmod +x ./cc-test-reporter
          ./cc-test-reporter before-build
        env:
          CC_TEST_REPORTER_ID: 6cbfbd07cb24649965a02f72f52ade4f63042525e86075ef38f04817d4fe8a67

      - name: Run tests
        env:
          PGHOST: localhost
          PGUSER: postgres
          PGPASSWORD: postgres
          RAILS_ENV: test
          RAILS_VERSION: ${{ matrix.rails-version }}
        run: COVERAGE=true bundle exec rspec --require rails_helper

      - name: Run code analysis
        run: bundle exec rake code_analysis

      - name: Report to CodeClimate
        run: |
          ./cc-test-reporter after-build --exit-code 0
        env:
          CC_TEST_REPORTER_ID: 6cbfbd07cb24649965a02f72f52ade4f63042525e86075ef38f04817d4fe8a67