Skip to content

Instantly share code, notes, and snippets.

@sabril
Last active October 23, 2019 03:26
Show Gist options
  • Save sabril/69b279759e4aa4cdf1a7ce4bb5a69ad7 to your computer and use it in GitHub Desktop.
Save sabril/69b279759e4aa4cdf1a7ce4bb5a69ad7 to your computer and use it in GitHub Desktop.
# .github/workflows/ci.yml
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1
- uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Install dependent libraries
run: sudo apt-get install libpq-dev
- name: Bundle install
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Setup Database
run: |
cp .github/workflows/database.yml.ci config/database.yml
bundle exec rake db:create
bundle exec rake db:schema:load
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
- name: Run Test
run: bundle exec rake
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
# .github/workflows/database.yml.ci
test:
adapter: postgresql
host: localhost
encoding: unicode
database: github-actions
pool: 20
username: <%= ENV["POSTGRES_USER"] %>
password: <%= ENV["POSTGRES_PASSWORD"] %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment