.circleci/config.yml
defaults: &defaults
parallelism: 1
working_directory: ~/workspace
docker:
- image: ruby:2.6
environment:
RAILS_ENV: test
DB_HOST_IP: 127.0.0.1
version: 2.1
jobs:
build:
<<: *defaults
steps:
- checkout
# Restore bundle cache & npm cache
- restore_cache:
key: 'rails-{{ checksum "Gemfile.lock" }}'
# Bundle install dependencies in /tmp/
# so Dockerfile does not copy them since
# its base image is different than CircleCI
- run:
name: Install bundler
command: gem install bundler:2.1.4
- run:
name: Bundle install
command: bundle install --path vendor/bundle --jobs=4 --retry=3
# Store bundle cache
- save_cache:
key: 'rails-{{ checksum "Gemfile.lock" }}'
paths:
- ~/workspace/vendor/bundle
- persist_to_workspace:
root: ~/workspace
paths:
- .
lint:
<<: *defaults
steps:
- attach_workspace:
at: ~/workspace
- run:
name: Install bundler
command: gem install bundler:2.1.4
- run:
name: Point bundle to vendor/bundle
command: bundle --path vendor/bundle
- run: bundle exec rubocop --display-only-fail-level-offenses --fail-level C
test-rspec:
<<: *defaults
steps:
- attach_workspace:
at: ~/workspace
- run:
name: Install bundler
command: gem install bundler:2.1.4
- run:
name: Point bundle to vendor/bundle
command: bundle --path vendor/bundle
- run: mkdir result
- run:
name: Running rspec
command: bundle exec rspec --format progress --format RspecJunitFormatter -o result/rspec.xml
when: always
- store_test_results:
path: ~/workspace/result
workflows:
version: 2
build-and-test:
jobs:
- build
- test-rspec:
requires:
- build
- lint:
requires:
- build