Skip to content

Instantly share code, notes, and snippets.

@krtschmr
Created October 9, 2019 11:09
Show Gist options
  • Save krtschmr/06b84948783617cd345ed2c34ad5d8ee to your computer and use it in GitHub Desktop.
Save krtschmr/06b84948783617cd345ed2c34ad5d8ee to your computer and use it in GitHub Desktop.
circle-ci integration rails 6, mysql 5.7, influx, redis, rspec + code covereage
version: 2 # use CircleCI 2.0
jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
parallelism: 1 # run three instances of this job in parallel
# branches:
# only:
# - master
docker: # run the steps with Docker
- image: circleci/ruby:2.6.3
environment: # environment variables for primary container
BUNDLE_JOBS: 1
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
RAILS_ENV: test
DB_HOST: 127.0.0.1
SATOSHISBANK_DATABASE_PASSWORD: ""
- image: circleci/mysql:5.7
steps: # a collection of executable commands
- checkout # special step to check out source code to working directory
- run:
name: Install System Dependencies
command: sudo apt-get update && sudo apt-get install -y nodejs influxdb redis-server
- run:
name: start influx & redis
command: sudo service influxdb start && sudo service redis-server start
# Restore bundle cache
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
- restore_cache:
keys:
- rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
- rails-demo-bundle-v2-
- run: # Install Ruby dependencies
name: Bundle Install
command: bundle check --path vendor/bundle || bundle install --deployment
# Store bundle cache for Ruby dependencies
- save_cache:
key: rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:3306 -timeout 1m
- run:
name: Database setup
command: bin/rails db:create db:schema:load
- run:
name: Run rspec in parallel
command: COVERAGE=true bundle exec rspec --format progress --format RspecJunitFormatter -o ~/test-results/rspec/rspec.xml
- store_artifacts:
path: coverage
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
path: ~/test-results/rspec/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment