name: Rails run RSpec tests

on: [push, pull_request]
  
jobs:
  build:

    runs-on: ubuntu-latest
    
    services:
      db:
        image: postgres:10.2
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        ports:
          - 5432:5432        
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
    - uses: actions/checkout@v2
    - uses: ruby/setup-ruby@v1.32.1      
      with:
        ruby-version: 2.5.4
    - name: Install dependencies and setup db
      env:
        RAILS_ENV: test
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: postgres
      run: |
        sudo apt-get -yqq install libpq-dev
        gem install bundler
        bundle install --jobs=3 --retry=3 --without production
        cp env.example .env
        cp config/database.yml.ci config/database.yml
        bundle exec rails db:create
        bundle exec rails db:migrate
    - name: Run tests
      env:
        RAILS_ENV: test
      run: |
        bundle exec rspec
      
        

name: Rails run RSpec tests

on: [push, pull_request]
  
jobs:
  build:

    runs-on: ubuntu-latest
    
    services:
      db:
        image: postgres:10.2
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        ports:
          - 5432:5432        
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
    - uses: actions/checkout@v2
    - uses: ruby/setup-ruby@v1.32.1      
      with:
        ruby-version: 2.5.4
    - name: Install dependencies and setup db
      env:
        RAILS_ENV: test
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: postgres
      run: |
        sudo apt-get -yqq install libpq-dev
        gem install bundler
        bundle install --jobs=3 --retry=3 --without production
        cp env.example .env
        cp config/database.yml.ci config/database.yml
        bundle exec rails db:create
        bundle exec rails db:migrate
    - name: Run tests
      env:
        RAILS_ENV: test
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: postgres
      run: |
        bundle exec rspec
      
        

Set postgres username and password when running tests
Set postgres username and password when running tests
