.circleci/config.yml
version: 2
jobs:
build:
working_directory: ~/maslow
environment:
CC_TEST_REPORTER_ID: 9cf59949508b77d574703e9fb321607ed17938e68d10b3e780c2a2772975ca64
docker:
- image: circleci/ruby:2.6.3-node
environment:
BUNDLE_JOBS: 3
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
PGHOST: 127.0.0.1
PGUSER: maslow
RAILS_ENV: test
TZ: London
- image: postgres:10
environment:
POSTGRES_USER: maslow
POSTGRES_DB: maslow_test
POSTGRES_PASSWORD: ""
steps:
- checkout # special step to check out source code to working directory
- run:
name: Setup Code Climate test-reporter
command: |
# download test reporter as a static binary
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
# Which version of bundler?
- run:
name: Which bundler?
command: bundle -v
# Restore bundle cache
- restore_cache:
keys:
- maslow-bundle-{{ checksum "Gemfile.lock" }}
- maslow-bundle-
- run:
name: Bundle Install
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
# Store bundle cache
- save_cache:
key: maslow-bundle-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Database setup
command: bin/rails db:schema:load --trace
- run:
name: Run rspec in parallel
command: |
./cc-test-reporter before-build
bundle exec rspec --profile 10 \
--format RspecJunitFormatter \
--out test_results/rspec.xml \
--format progress \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
# Save test results for timing analysis
- store_test_results:
path: test_results