Created
August 14, 2020 16:30
-
-
Save coderberry/b6b005d93fbd19369d720d68cd788e55 to your computer and use it in GitHub Desktop.
Using GitHub Actions for CI (rspec + rubocop)
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
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
env: | |
RAILS_ENV: test | |
DATABASE_URL: postgres://postgres:postgres@localhost | |
jobs: | |
ruby_dependencies: | |
name: Ruby - download and cache dependencies | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install Ruby version specified in `.ruby-version` | |
uses: eregon/use-ruby-action@master | |
- name: Ruby gem cache | |
uses: actions/cache@v1 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: ${{ runner.os }}-gems- | |
- name: Install gems | |
run: bundle install --jobs 4 --retry 3 --path vendor/bundle | |
rspec: | |
name: Run RSpec | |
runs-on: ubuntu-latest | |
needs: ruby_dependencies | |
services: | |
postgres: | |
image: postgres:12.3-alpine | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install Ruby version specified in `.ruby-version` | |
uses: eregon/use-ruby-action@master | |
- name: Ruby gem cache | |
uses: actions/cache@v1 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: ${{ runner.os }}-gems- | |
- name: Install gems | |
run: bundle install --jobs 4 --retry 3 --path vendor/bundle | |
- name: Setup test database | |
run: bundle exec rails db:create db:migrate | |
- name: Run RSpec | |
run: bundle exec rspec | |
rubocop: | |
name: Run Rubocop | |
runs-on: ubuntu-latest | |
needs: ruby_dependencies | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install Ruby version specified in `.ruby-version` | |
uses: eregon/use-ruby-action@master | |
- name: Ruby gem cache | |
uses: actions/cache@v1 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: ${{ runner.os }}-gems- | |
- name: Install gems | |
run: bundle install --jobs 4 --retry 3 --path vendor/bundle | |
- name: Run Rubocop | |
run: bundle exec rubocop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment