alecdotninja/active_record_distinct_on

View on GitHub
.github/workflows/test.yml

Summary

Maintainability
Test Coverage
name: Test
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        ruby:
          - '3.0.5'
          - '3.1.4'
          - '3.2.2'
        rails:
          - '6.1'
          - '7.0'
          - '7.1'
    services:
      postgres:
        image: postgres:13
        env:
          POSTGRES_PASSWORD: 'password'
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

    steps:
      - uses: actions/checkout@v2
      - name: Setup Ruby ${{ matrix.ruby }}
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}

      - name: Setup Bundler
        run: |
          gem update --system --no-doc
          gem install bundler --no-doc
          bundle config set path "vendor/bundle"

      - name: Install Gems for Rails ${{ matrix.rails }}
        env:
          BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
        run: |
          bundle check || bundle install --jobs 4 --retry 3

      - name: Prepare Code Climate Test Reporter
        uses: aktions/codeclimate-test-reporter@v1
        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
        with:
          codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
          command: before-build

      - name: Run Test Suite (sqlite)
        env:
          BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
        run: |
          bundle exec rake

      - name: Run Test Suite (postgres)
        env:
          BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
        run: |
          PGPASSWORD=password psql -h localhost -U postgres -c 'create database active_record_distinct_on_test;'
          DATABASE_URL='postgresql://postgres:password@localhost/active_record_distinct_on_test' bundle exec rake

      - name: Upload Coverage Report
        uses: aktions/codeclimate-test-reporter@v1
        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
        with:
          codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
          command: after-build