sferik/rails_admin

View on GitHub
.github/workflows/test.yml

Summary

Maintainability
Test Coverage
name: Test

on: [push, pull_request]

jobs:
  rspec:
    name: RSpec
    strategy:
      fail-fast: false
      matrix:
        ruby:
          - "3.0"
          - "3.1"
          - "3.2"
          - "3.3"
        gemfile: [gemfiles/rails_7.1.gemfile]
        orm: [active_record]
        adapter: [sqlite3]
        asset: [webpack]
        include:
          - ruby: 2.6
            gemfile: gemfiles/rails_6.0.gemfile
            orm: active_record
            adapter: sqlite3
            asset: sprockets
          - ruby: 2.7
            gemfile: gemfiles/rails_6.1.gemfile
            orm: active_record
            adapter: sqlite3
            asset: sprockets
          - ruby: 2.7
            gemfile: gemfiles/rails_6.1.gemfile
            orm: active_record
            adapter: sqlite3
            asset: webpacker
          - ruby: "3.2"
            gemfile: gemfiles/rails_7.0.gemfile
            orm: active_record
            adapter: sqlite3
            asset: sprockets
          - ruby: "3.2"
            gemfile: gemfiles/rails_7.1.gemfile
            orm: active_record
            adapter: mysql2
            asset: importmap
          - ruby: "3.2"
            gemfile: gemfiles/rails_7.1.gemfile
            orm: active_record
            adapter: postgresql
            asset: sprockets
          - ruby: "3.2"
            gemfile: gemfiles/rails_7.1.gemfile
            orm: active_record
            adapter: sqlite3
            asset: vite
          - ruby: "3.3"
            gemfile: gemfiles/rails_7.2.gemfile
            orm: active_record
            adapter: sqlite3
            asset: sprockets
          - ruby: "3.2"
            gemfile: gemfiles/composite_primary_keys.gemfile
            orm: active_record
            adapter: sqlite3
            asset: sprockets
          - ruby: 2.7
            gemfile: gemfiles/rails_6.0.gemfile
            orm: mongoid
            adapter: sqlite3
            asset: sprockets
          - ruby: "3.0"
            gemfile: gemfiles/rails_6.1.gemfile
            orm: mongoid
            adapter: sqlite3
            asset: sprockets
          - ruby: "3.1"
            gemfile: gemfiles/rails_7.0.gemfile
            orm: mongoid
            adapter: sqlite3
            asset: sprockets
          - ruby: "3.2"
            gemfile: gemfiles/rails_7.1.gemfile
            orm: mongoid
            adapter: sqlite3
            asset: sprockets
          - ruby: jruby-9.4
            gemfile: gemfiles/rails_7.0.gemfile
            orm: active_record
            adapter: mysql2
            asset: sprockets
          - ruby: jruby-9.4
            gemfile: gemfiles/rails_7.0.gemfile
            orm: mongoid
            adapter: sqlite3
            asset: sprockets
    runs-on: ubuntu-latest
    services:
      mysql:
        image: mysql:8.0
        ports:
          - 3306:3306
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: yes
      postgres:
        image: postgres:11
        ports:
          - 5432:5432
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
      mongo:
        image: mongo:4.4
        ports:
          - 27017:27017
    env:
      BUNDLE_GEMFILE: ${{ matrix.gemfile }}
      CI_ORM: ${{ matrix.orm }}
      CI_ASSET: ${{ matrix.asset }}
      JRUBY_OPTS: --debug
    steps:
      - uses: actions/checkout@v4
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true
          cache-version: gems-${{ hashFiles('Gemfile', 'gemfiles/*.gemfile') }}
        env:
          MAKEFLAGS: make --jobs 4
          BUNDLE_WITHOUT: development
      - name: Set up Node
        uses: actions/setup-node@v4
        with:
          node-version: "18"
      - name: Install ImageMagick
        run: sudo apt-get install imagemagick
      - name: Setup application
        env:
          BUNDLE_GEMFILE: ../../${{ matrix.gemfile }}
          CI_ASSET: ${{ matrix.asset }}
          CI_DB_ADAPTER: ${{ matrix.adapter }}
          RAILS_ENV: test
          NODE_OPTIONS: --openssl-legacy-provider
        run: |
          yarn install
          cd spec/dummy_app
          bundle exec rake rails_admin:prepare_ci_env db:create db:migrate
          yarn install
          case "$CI_ASSET" in
          "webpack" ) yarn build && yarn build:css ;;
          "importmap" ) yarn build:css ;;
          esac
          cd ../../
      - name: Run tests
        run: bundle exec rspec
      - name: Coveralls Parallel
        if: ${{ github.repository_owner == 'railsadminteam' }}
        uses: coverallsapp/github-action@v2
        continue-on-error: true
        with:
          github-token: ${{ secrets.github_token }}
          flag-name: run-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ matrix.orm }}-${{ matrix.adapter }}
          parallel: true

  coveralls:
    name: Coveralls
    if: ${{ github.repository_owner == 'railsadminteam' }}
    needs: rspec
    runs-on: ubuntu-latest
    steps:
      - name: Coveralls Finished
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ secrets.github_token }}
          parallel-finished: true

  prettier:
    name: Prettier
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Node.js
        uses: actions/setup-node@v4
      - name: Install dependencies
        run: yarn install
      - name: Run check
        run: yarn run prettier --check .

  rubocop:
    name: RuboCop
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: "3.2"
          bundler-cache: true
          cache-version: gems-${{ hashFiles('Gemfile') }}
      - name: Install dependencies
        run: bundle install --without development --jobs=3 --retry=3 --path=vendor/bundle
      - name: Run check
        run: bundle exec rake rubocop