Skip to content

Instantly share code, notes, and snippets.

@despo
Created October 29, 2020 17:13
Show Gist options
  • Save despo/0106e9e8e874fa79907c3537abfdbac1 to your computer and use it in GitHub Desktop.
Save despo/0106e9e8e874fa79907c3537abfdbac1 to your computer and use it in GitHub Desktop.
Gtihub actions for Rails 6
# 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:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11.5
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
with:
ruby-version: 2.7.1
- name: Install dependencies
run: |
sudo apt-get -yqq install libpq-dev build-essential libcurl4-openssl-dev
gem install bundler
bundle install --jobs 4 --retry 3
yarn install
- name: Setup test database
env:
DATABASE_URL: postgres://postgres:@localhost:5432/test
RAILS_ENV: test
run:
rake db:create db:migrate
- name: Run style check
run: bundle exec rake rubocop
- name: Run tests
env:
DATABASE_URL: postgres://postgres:@localhost:5432/test
RAILS_ENV: test
run: bundle exec rake spec
@despo
Copy link
Author

despo commented Oct 29, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment