Skip to content

Instantly share code, notes, and snippets.

@cftang0827
Created September 10, 2019 01:19
Show Gist options
  • Save cftang0827/2a9a4651e6c0c71475b6c8e5dcd7a96a to your computer and use it in GitHub Desktop.
Save cftang0827/2a9a4651e6c0c71475b6c8e5dcd7a96a to your computer and use it in GitHub Desktop.
version: 2
jobs:
build:
working_directory: ~/circleci-demo-ruby-rails
# Primary container image where all commands run
docker:
- image: circleci/ruby:2.4.1-node
environment:
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root
# Service container image available at `host: localhost`
- image: circleci/postgres:9.6.2-alpine
environment:
POSTGRES_USER: root
POSTGRES_DB: circle-test_test
steps:
- checkout
# Restore bundle cache
- restore_cache:
keys:
- rails-demo-{{ checksum "Gemfile.lock" }}
- rails-demo-
# Bundle install dependencies
- run:
name: Install dependencies
command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs 4 --retry 3
- run: sudo apt install -y postgresql-client || true
# Store bundle cache
- save_cache:
key: rails-demo-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Database Setup
command: |
bundle exec rake db:create
bundle exec rake db:structure:load
- run:
name: Parallel RSpec
command: bin/rails test
# Save artifacts
- store_test_results:
path: /tmp/test-results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment