Skip to content

Instantly share code, notes, and snippets.

Created October 9, 2019 11:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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_PATH: vendor/bundle
- 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:
- restore_cache:
- 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" }}
- 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:
path: ~/test-results/rspec/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment