Skip to content

Instantly share code, notes, and snippets.

@hahmed
Created May 23, 2018 11:46
Show Gist options
  • Save hahmed/aafd37e8d92adbecc6bd6d6b766d13ea to your computer and use it in GitHub Desktop.
Save hahmed/aafd37e8d92adbecc6bd6d6b766d13ea to your computer and use it in GitHub Desktop.
Circle ci setup
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/ruby:2.4.1-node-browsers
environment: # environment variables for primary container
BUNDLE_JOBS: 3
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
RAILS_ENV: test
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
working_directory: ~/todo_next
steps:
- checkout
# Which version of bundler?
- run:
name: Which bundler?
command: bundle -v
# Restore bundle cache
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: install dependencies
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
# Store bundle cache
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
- run:
name: webpacker
command: bundle exec rails webpacker:compile
# Only necessary if app uses webpacker or yarn in some other way
- restore_cache:
keys:
- surventrix-yarn-{{ checksum "yarn.lock" }}
- surventrix-yarn-
- run:
name: Yarn Install
command: yarn install --cache-folder ~/.cache/yarn
# Store yarn / webpacker cache
- save_cache:
key: surventrix-yarn-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
# Database setup
- run: bundle exec rake db:create
- run: bundle exec rake db:schema:load
# run tests!
- run:
name: run tests
command: |
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
bundle exec rspec --format progress \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress \
$TEST_FILES
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment