khiav223577/atomically

View on GitHub
.github/workflows/ruby.yml

Summary

Maintainability
Test Coverage
name: Ruby

on:
  push:
    paths-ignore:
      - 'README.md'
      - 'CHANGELOG.md'
  pull_request:
    branches: [ master ]
    paths-ignore:
      - 'README.md'
      - 'CHANGELOG.md'

jobs:
  test:
    runs-on: ubuntu-latest
    name: Test
    if: "contains(github.event.commits[0].message, '[ci skip]') == false"
    strategy:
      fail-fast: false
      matrix:
        db:
          - mysql
          - pg
        ruby:
          # - 2.2 # skip Ruby 2.2 since mysql2 raises segmentation fault at 0x0000000000000000
          # See: https://github.community/t/mysql2-segmentation-fault-at-0x0000000000000000/159283
          - 2.6
          - 2.7
        gemfile:
          - 3.2.gemfile
          - 4.2.gemfile
          - 5.0.gemfile
          - 5.1.gemfile
          - 5.2.gemfile
          - 6.0.gemfile
        exclude:
          - gemfile: 3.2.gemfile
            ruby: 2.6
          - gemfile: 3.2.gemfile
            ruby: 2.7
          - gemfile: 4.2.gemfile
            ruby: 2.7
          - gemfile: 6.0.gemfile
            ruby: 2.2
        include:
          - db: makara_mysql
            gemfile: 6.0.gemfile
            ruby: 2.6
          - db: makara_pg
            gemfile: 6.0.gemfile
            ruby: 2.6
          - db: makara_mysql
            gemfile: 6.0.gemfile
            ruby: 2.7
          - db: makara_pg
            gemfile: 6.0.gemfile
            ruby: 2.7
    env:
      BUNDLE_GEMFILE: "gemfiles/${{ matrix.gemfile }}"
      DB: "${{ matrix.db }}"

    services:
      mysql:
        image: mysql:5.6
        env:
          MYSQL_ROOT_PASSWORD: root_password
          MYSQL_USER: developer
          MYSQL_PASSWORD: developer_password
          MYSQL_DATABASE: github_actions_test
        ports:
          - 3306:3306
        # Set health checks to wait until mysql has started
        options: >-
          --health-cmd "mysqladmin ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 3
      postgres:
        image: postgres:9.6
        env:
          POSTGRES_USER: developer
          POSTGRES_PASSWORD: developer_password
          POSTGRES_DB: github_actions_test
        ports:
          - 5432:5432
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 3

    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Setup Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: ${{ matrix.ruby }}
        bundler-cache: true # runs 'bundle install' and caches installed gems automatically
    - name: Run tests
      run: bundle exec rake
    - name: Publish code coverage
      if: ${{ success() }}
      uses: paambaati/codeclimate-action@v2.7.5
      env:
        CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}