shioyama/mobility

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
name: CI

on:
  push:
    branches:
      - master
      - 1-2
      - 1-1
      - 1-0
      - 0-8
  pull_request:
    branches:
      - master
      - 1-2
      - 1-1
      - 1-0
      - 0-8

jobs:
  test:
    runs-on: ubuntu-latest
    continue-on-error: ${{ matrix.experimental }}
    name: ${{ matrix.feature }} ruby-${{ matrix.ruby }} ${{ matrix.orm.name }}-${{ matrix.orm.version}} ${{ matrix.database }}
    strategy:
      fail-fast: false
      matrix:
        ruby:
          - '3.0'
          - '2.7'
          - '2.6'
        database:
          - 'sqlite3'
          - 'mysql'
          - 'postgres'
        orm:
          - name: 'active_record'
            version: '4.2'
          - name: 'active_record'
            version: '5.0'
          - name: 'active_record'
            version: '5.1'
          - name: 'active_record'
            version: '5.2'
          - name: 'active_record'
            version: '6.0'
          - name: 'active_record'
            version: '6.1'
          - name: 'active_record'
            version: '7.0'
          - name: 'sequel'
            version: '5'
        experimental: [false]
        feature: ['unit']
        include:
          - ruby: '3.0'
            feature: 'unit'
            orm:
            experimental: false
          - ruby: '2.7'
            feature: 'unit'
            orm:
            experimental: false
          - ruby: '2.6'
            feature: 'unit'
            orm:
            experimental: false
          - ruby: '3.0'
            feature: 'rails'
            orm:
              name: 'active_record'
              version: '7.0'
            database: 'sqlite3'
            experimental: false
          - ruby: '3.0'
            feature: 'performance'
            experimental: false
          - ruby: '3.0'
            feature: 'i18n_fallbacks'
            experimental: false
          - ruby: '3.0'
            database: 'sqlite3'
            feature: 'unit'
            orm:
              name: 'active_record'
              version: 'edge'
            experimental: true
          - ruby: '3.0'
            database: 'mysql'
            feature: 'unit'
            orm:
              name: 'active_record'
              version: 'edge'
            experimental: true
          - ruby: '3.0'
            database: 'postgres'
            feature: 'unit'
            orm:
              name: 'active_record'
              version: 'edge'
            experimental: true
          - ruby: '2.7'
            feature: 'rails'
            orm:
              name: 'active_record'
              version: '7.0'
            database: 'sqlite3'
            experimental: false
          - ruby: '2.7'
            feature: 'performance'
            experimental: false
          - ruby: '2.7'
            feature: 'i18n_fallbacks'
            experimental: false
          - ruby: '2.7'
            database: 'sqlite3'
            feature: 'unit'
            orm:
              name: 'active_record'
              version: 'edge'
            experimental: true
          - ruby: '2.7'
            database: 'mysql'
            feature: 'unit'
            orm:
              name: 'active_record'
              version: 'edge'
            experimental: true
          - ruby: '2.7'
            database: 'postgres'
            feature: 'unit'
            orm:
              name: 'active_record'
              version: 'edge'
            experimental: true
        exclude:
          - ruby: '2.6'
            orm:
              name: 'active_record'
              version: '7.0'
          - ruby: '2.7'
            orm:
              name: 'active_record'
              version: '4.2'
          - ruby: '3.0'
            orm:
              name: 'active_record'
              version: '4.2'
          - ruby: '3.0'
            orm:
              name: 'active_record'
              version: '5.0'
          - ruby: '3.0'
            orm:
              name: 'active_record'
              version: '5.1'
          - ruby: '3.0'
            orm:
              name: 'active_record'
              version: '5.2'
    env:
      DB: ${{ matrix.database }}
      BUNDLE_JOBS: 4
      BUNDLE_PATH: vendor/bundle
      ORM: ${{ matrix.orm.name }}
      ORM_VERSION: ${{ matrix.orm.version }}
      MYSQL_PASSWORD: root
      PGHOST: localhost
      PGPORT: 5432
      PGUSER: postgres
      RAILS_ENV: test
      FEATURE: ${{ matrix.feature }}

    services:
      postgres:
        image: postgres:11.5
        ports: ["5432:5432"]
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

      mysql:
        image: mysql:5.7
        ports: ["3306:3306"]
        options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
        env:
          MYSQL_ROOT_PASSWORD: root

    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Update packages
        run: sudo apt-get update
      - name: Install Sqlite
        run: sudo apt-get install libsqlite3-dev -y
        if: matrix.database == 'sqlite3'
      - name: Install Postgres
        run: sudo apt-get install libpq-dev postgresql-client -y
        if: matrix.database == 'postgres'
      - id: cache-bundler
        uses: actions/cache@v2
        with:
          path: vendor/bundle
          key: ${{ matrix.ruby }}-${{ matrix.orm.name }}-${{ matrix.orm.version }}-${{ matrix.feature }}-${{ hashFiles('mobility.gemspec') }}-${{ hashFiles('Gemfile') }}
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
      - name: Install latest Bundler
        run: gem install bundler --no-document
      - name: Install dependencies
        run: bundle install
      - name: Setup test db
        run: bundle exec rake db:create db:up
        if: matrix.database
      - name: Run tests
        run: bundle exec rake