Merge pull request #107 from happy-software/sidekiq_isnt_working #362
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 runs two separate jobs, one to lint with Rubocop, the other to test with Rspec | |
name: Ruby CI | |
# Trigger the workflow on push or pull request | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
rubocop-lint: | |
name: Rubocop | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
- name: Install Rubocop | |
run: gem install rubocop | |
- name: Run Rubocop | |
# Allow Rubocop to run without breaking the workflow | |
continue-on-error: true | |
# Only run Rubocop on changed files | |
run: | | |
git fetch origin ${{ github.event.pull_request.base.sha }} | |
git diff -r --name-only ${{ github.event.pull_request.base.sha }} | grep '\.rb$' | xargs -r rubocop | |
rspec-test: | |
name: Rspec | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
# Docker Hub image | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
# runs `bundle install` and caches gems | |
bundler-cache: true | |
- name: Install dependencies | |
run: bundle install | |
- name: Run database setup | |
run: | | |
sudo apt-get install libpq-dev | |
RAILS_ENV=test bundler exec rails db:create db:migrate | |
env: | |
POSTGRES_HOST: localhost | |
POSTGRES_PORT: 5432 | |
DB_USERNAME: postgres | |
DB_PASSWORD: postgres | |
- name: Run Rspec tests | |
run: bundler exec rspec | |
env: | |
POSTGRES_HOST: localhost | |
POSTGRES_PORT: 5432 | |
DB_USERNAME: postgres | |
DB_PASSWORD: postgres | |
# need to setup SimpleCov for Rspec | |
# @see https://jer-k.github.io/github-action-rspec-simplecov | |
# - name: Upload coverage results | |
# uses: actions/upload-artifact@master | |
# with: | |
# name: coverage-report | |
# path: coverage |