Arie/serveme

View on GitHub
.github/workflows/rails.yml

Summary

Maintainability
Test Coverage
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby
on: [push, pull_request]

jobs:
  ruby-dependencies:
    name: Ruby dependencies
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Install dependencies
        run: |
          sudo add-apt-repository ppa:maxmind/ppa
          sudo apt update
          sudo apt install libmaxminddb0 libmaxminddb-dev redis-server memcached
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Install gems
        run: |
          bundle config path vendor/bundle
          bundle install --jobs 4 --retry 3
  rubocop:
    name: Rubocop
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
      - name: Install Rubocop
        run: gem install rubocop
      - name: Check code
        run: rubocop app
  rspec:
    name: RSpec
    runs-on: ubuntu-latest
    needs: [ruby-dependencies]
    services:
      postgres:
        image: postgres:13
        env:
          POSTGRES_USER: serveme
          POSTGRES_DB: serveme_test
          POSTGRES_PASSWORD: secret
        ports: ["5432:5432"]
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Install dependencies
        run: |
          sudo add-apt-repository ppa:maxmind/ppa
          sudo apt update
          sudo apt install libmaxminddb0 libmaxminddb-dev redis-server memcached
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Setup test database
        env:
          RAILS_ENV: test
          PGHOST: localhost
          PGUSER: serveme
          PGPASSWORD: secret
        run: |
          bin/rails db:create db:migrate

      - name: Run RSpec tests
        env:
          RAILS_ENV: test
          PGHOST: localhost
          PGUSER: serveme
          PGPASSWORD: secret
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
        run: bundle exec rspec spec

  cucumber:
    name: Cucumber
    runs-on: ubuntu-latest
    needs: [ruby-dependencies]

    services:
      postgres:
        image: postgres:13
        env:
          POSTGRES_USER: serveme
          POSTGRES_DB: serveme_test
          POSTGRES_PASSWORD: secret
        ports: ["5432:5432"]
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Install dependencies
        run: |
          sudo add-apt-repository ppa:maxmind/ppa
          sudo apt update
          sudo apt install libmaxminddb0 libmaxminddb-dev redis-server memcached
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Setup test database
        env:
          RAILS_ENV: test
          PGHOST: localhost
          PGUSER: serveme
          PGPASSWORD: secret
        run: |
          bin/rails db:create db:migrate
      - name: Run Cucumber features
        env:
          RAILS_ENV: test
          PGHOST: localhost
          PGUSER: serveme
          PGPASSWORD: secret
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
        run: bundle exec cucumber features