Skip to content

Instantly share code, notes, and snippets.

@moviendome
Created June 2, 2021 05:28
Show Gist options
  • Save moviendome/5733096c06eb620f19f585de02e6bd6b to your computer and use it in GitHub Desktop.
Save moviendome/5733096c06eb620f19f585de02e6bd6b to your computer and use it in GitHub Desktop.
name: Rails
on: push
jobs:
verify:
name: Build
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: rails_github_actions
POSTGRES_DB: rails_github_actions_test
POSTGRES_PASSWORD: postgres
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server
steps:
- uses: actions/checkout@v1
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
bundler-cache: true
- name: Install dependencies
run: |
sudo apt-get -yqq install libpq-dev build-essential
gem install bundler
bundle install --jobs 4 --retry 3
- name: Setup test database
env:
RAILS_ENV: test
PGHOST: localhost
POSTGRES_DB: rails_github_actions_test
POSTGRES_USER: rails_github_actions
POSTGRES_PASSWORD: postgres
run: |
cp config/database.ci.yml config/database.yml
bundle exec rake db:create db:migrate
- name: Run tests
env:
PGHOST: localhost
POSTGRES_DB: rails_github_actions_test
POSTGRES_USER: rails_github_actions
POSTGRES_PASSWORD: postgres
PGPORT: ${{ job.services.postgres.ports[5432] }}
REDIS_URL: redis://localhost:6379/0
RAILS_ENV: test
run: bin/rails t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment